HTML Formatter, Minifier and Beautifier
Clean up markup, or squeeze it down for production.
INPUT
CHARS: 0WORDS: 0LINES: 0
OUTPUT
CHARS: 0WORDS: 0LINES: 0
How the HTML Formatter, Minifier and Beautifier works
Beautify mode parses the document and prints it with nested elements indented, long attribute lists wrapped and inline elements kept inline so that text does not gain stray spaces. Embedded style and script blocks are formatted with the matching language rules.
Minify mode removes comments, collapses whitespace between tags and keeps the content of pre, textarea, script and style elements untouched. Treat minify as a lightweight step, since a build pipeline can also compress CSS and JavaScript and rename identifiers.
HTML Formatter, Minifier and Beautifier examples
Beautify compressed HTML markup
Input
<div class="hero"><h1>ConvertCasePro</h1><p>Free text tools.</p></div>
Result
<div class="hero"> <h1>ConvertCasePro</h1> <p>Free text tools.</p> </div>
When it is useful
- •Reading the source of a page that was served minified.
- •Reformatting email templates and CMS output for editing.
- •Reducing the size of a static snippet.
- •Spotting unclosed or misnested tags.
Frequently Asked Questions
Will formatting change how the page looks?
The formatter is whitespace aware for inline elements, so rendering should not change. If you rely on exact whitespace inside an element, check pre and inline blocks after formatting.
Can it fix broken HTML?
It parses HTML leniently like a browser does, so many errors are tolerated. It will not rewrite markup to be valid.
Does it convert HTML to Markdown?
Use the HTML to Markdown Converter for that.
Related tools
- XML FormatterPaste XML to check it and lay it out with clear indentation.
- CSS FormatterPaste CSS and get tidy, consistently indented code, or a compact minified version.
- JavaScript FormatterMake minified or messy JavaScript readable.
- HTML to Markdown ConverterPaste HTML and get Markdown you can drop into a README, a wiki or a static site.