🌐
FreeFormatter
freeformatter.com β€Ί html-formatter.html
Free Online HTML Formatter - FreeFormatter.com
This free online HTML formatter and validator lets you chose your indentation level and also lets you export to file
🌐
HTML Corrector
htmlcorrector.com
HTML corrector (HTML fixing tool). Makes HTML valid 🧰
HTML Corrector is a tool that corrects HTML so it becomes valid HTML Β· Copy & pasteUpload Β· PasteExampleClear Β· Correct Β· Fixes or removes non-well formed tags and attributes Β· Converts the markup to HTML5 (if it is XHTML for example) Reformats ...
People also ask

How do I format and clean HTML?
Paste your code and click Pretty to format, remove clutter, and apply your selected tidy options.
🌐
htmltidy.net
htmltidy.net
Pretty HTML – HTML Formatter, Editor & Cleaner
Can I export to DOCX?
Yes. Click Docx to download a Word document generated from your current HTML.
🌐
htmltidy.net
htmltidy.net
Pretty HTML – HTML Formatter, Editor & Cleaner
Can I open .docx files?
Yes. Drag-and-drop a DOCX file or use the picker; the app converts it to HTML in your browser.
🌐
htmltidy.net
htmltidy.net
Pretty HTML – HTML Formatter, Editor & Cleaner
🌐
Web Formatter
webformatter.com β€Ί html
HTML Formatter
Simply paste your HTML code into the editor, or upload an HTML file using the UPLOAD button. You can also drag and drop files directly onto the editor. Click the FORMAT button and watch your code transform into beautifully structured HTML. Adjust the TAB SIZE if you prefer different indentation ...
🌐
Pretty HTML
htmltidy.net
Pretty HTML – HTML Formatter, Editor & Cleaner
Pretty HTML was previously available as HTML Tidy (HTMLtidy.net) since 2016. Since then it has the same core features: a web browser application whose purpose is to fix invalid web code, beautify the layout and formatting of the incorrect markup. The user interface is composed of two editors ...
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί html β€Ί html-formatter
HTML Formatter - GeeksforGeeks
July 23, 2025 - HTML Formatter or Beautifier tools help make your HTML code clean and easy to read. They fix the spacing, line up elements properly, and highlight parts of the code, so it's easier to understand and work with.
🌐
Site24x7
site24x7.com β€Ί tools β€Ί html-beautifier.html
HTML Beautifier | Beautify HTML Code Online - Site24x7 Tools
Beautify HTML code into a human-readable and understandable format using our HTML Beautifier.
🌐
HTML Washer
htmlwasher.com
HTML Cleaner β€” Clean Up & Simplify HTML Online 🧰
Headings, tables, lists, code blocks, b/i/s formatting Β· Standard Β· Standard Reader Β· Includes images, video/audio, figures, blockquotes Β· Permissive Β· Permissive Reader Β· Includes structural HTML5, details/summary, divs/spans Β· Styled Β· Styled Reader Β· Includes CSS classes, style attributes, and <style> tags Β· Correct only Β· Normalize HTML without cleanup Β· Minify Β· Wash Β· Fixes malformed HTML (unclosed tags, invalid nesting) Reduces the markup to: <html lang>, <head>, <meta charset name content>, <title>, <body>, <p>, <blockquote cite>, <hr>, <figure>, <figcaption>, <a href tit
🌐
Htmlformatter
htmlformatter.com
HTML Formatter
An online HTML formatter and validator to check and improve ugly or minified HTML code, giving it the correct indentation.
Find elsewhere
🌐
HTML Cleaner
html-cleaner.com
HTML Cleaner - Online Beautifyer and Word Converter
Get rid of your dirty markup with the free online HTML Cleaner. Easy to compose, edit, format and minify the web code with this online tool. Convert Word, Excel to tidy HTML
🌐
Galaxy
galaxy.ai β€Ί ai-html-fixer
Free HTML Fixer (No Login Required) | Galaxy.ai
Fix and beautify your HTML code instantly with our free AI-powered HTML Fixer. Clean up messy markup, fix errors, and improve code formatting - no login required.
🌐
Static.app
static.app β€Ί html-formatter
Free Online HTML Formatter - Static.app
Directly copy and paste unformatted HTML code into the form above. ... Click the β€œFormat” button to begin the HTML formatting process.
🌐
Brokenhtml
brokenhtml.com
Fix HTML tags broken by machine translation tools
HTML tags broken after the Google machine translation, repair your broken HTML tags here. This tool will batch repair the broken HTML tags after machine translation broke the html code.
🌐
BeautifyTools
beautifytools.com β€Ί html-beautifier.php
Online HTML Beautifier - HTML Formatter - BeautifyTools.com
Online HTML Beautifier and HTML Formatter beautifies dirty, ugly or minified HTML code and give it proper indentation. It also format the css between the style tags and the javascript between the script tags.
🌐
CodeBeautify
codebeautify.org β€Ί htmlviewer
Best HTML Viewer, HTML Beautifier, HTML Formatter and to Test / Preview HTML Output
Online HTML Viewer, HTML Beautifier, HTML Formatter, HTML Editor to Test output - Convert HTML Strings to a Friendly Readable Format, Beautify.
🌐
Word to HTML
wordtohtml.net β€Ί html-cleaner
HTML Cleaner Online Tool - Paste or Upload HTML Code to Fix & Optimize
Paste or upload your HTML code to automatically remove clutter, fix formatting, and generate clean, valid HTML.
🌐
W3Schools
w3schools.com β€Ί html β€Ί html_formatting.asp
HTML Text Formatting
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
🌐
SmallDev
smalldev.tools β€Ί html-formatter-online
Online HTML formatter, HTML beautifier - SmallDev.tools
This online formatter tools uses Javascript formatting library which makes it easier to format the code. The library works by using regular expressions on the source code. Regular expression matches the codes and add appropiate indentations, wrap lines and remove extra lines. ... Input HTML code: <html><head><meta charset="utf-8"><title>Test title</title></head><body></body></html>
Top answer
1 of 1
6

Why is text formatting in code blocks now broken?

This is caused by a change to the syntax highlighter used by Stack Overflow, Highlight.js. As of version 11 (released May 2021), support for HTML merging (using HTML elements inside code blocks to format text) has been removed from the highlighter. When highlighting, it now pulls the plain text version of the rich text (using the JavaScript property textContent), which strips out any HTML tags when performing highlighting.

Note that this applies only to code blocks formatted using the HTML <pre><code> elements. For blocks formatted using four-space indent or triple backticks (```), HTML elements are, and always have been, rendered as text rather than being applied or stripped as with the latter type of block.

Why was this change made?

Per the announcement from the maintainers of Highlight.js, this change was made in order to reduce the chances of HTML injection security vulnerabilities. (Keep in mind that while HTML is sanitized in Stack Overflow posts, Highlight.js is a general library maintained outside of Stack Exchange and used by many others, many of whom don't perform HTML sanitizing.)

What posts and/or code blocks are affected?

Essentially, any code block for which syntax highlighting is being performed is affected by this change, and will have HTML tags inside the code block stripped out instead of applied to text. Per that link, syntax highlighting is performed on posts depending on the tags used on the question. If at least one tag on the question has a highlighting language specified, all code blocks in the question and its answers (which don't explicitly have highlighting disabled) will be highlighted.

If no highlighting is being performed for a given code block (either because none of the tags have highlighting hints specified or because highlighting is explicitly disabled for the code block or post), it is unaffected by this change, and HTML formatting will continue to be applied as before.

How can I fix broken posts?

The easiest way to fix a post that depended on this removed feature (which used HTML elements to format text inside code blocks) is to explicitly disable syntax highlighting for the specific code blocks or for the entire post using an HTML comment.

To disable highlighting for an individual code block, place the following comment before the <pre><code> elements as below:

<!-- language: lang-none -->
<pre><code>
...

To disable highlighting for an entire post (question or answer), place the following comment at the very beginning of the post:

<!-- language-all: lang-none -->

Do note that when the above comment is used on a question, it will only affect highlighting for that question and not for its answers, which will still be highlighted as per the question's tags unless manually overridden within the answer itself.

Why does it appear to render correctly in the post preview, but not in the actual post?

This happens because there's a 5-second window between when you make an edit in the post editor and when highlighting is performed in the post preview. If you wait 5 seconds after typing anything into the post preview, you'll notice that the highlighter kicks in and any formatting inside the code blocks will be stripped out in the preview.

This whole change is nonsense! Can't Stack Overflow work around it somehow?

Turns out, they can! The original announcement of this change from Highlight.js contains code for a plugin which allows for restoring the prior functionality of HTML formatting in code blocks, making it so it's no longer necessary to repair broken posts or worry about unexpected changes in the preview. Installing it would also fix the issue that syntax highlighting had to be disabled in revision histories and suggested edits.

That said, there are downsides to installing the plugin. This would require dev team effort to fix a very small percentage of posts, and can be worked around for the small number of affected posts.

There's currently a discussion going on as to whether the plugin should be installed; feel free to chime in.

Tangential question: how can I actually put HTML tags as text within HTML <pre><code> blocks?

Simply encode the < and > signs as HTML entities &lt; and &gt;.

🌐
DhiWise
dhiwise.com β€Ί post β€Ί insider-tips-for-perfecting-html-code-formatting
Master Readable HTML: Essential Guide to HTML Code Formatting
June 3, 2024 - HTML formatting involves arranging your HTML source code in a way that it becomes easy to read and understand. Proper indentation, use of line breaks, and consistent spacing are key elements.