DevTools

HTML Formatter

Format and minify HTML markup.

Input

0 chars

Output

About HTML Formatter

Pretty-print messy or minified HTML, or strip it back down. Formatting is done by Prettier compiled to run in the browser, so the result matches what your editor would produce.

Whitespace is not always insignificant

In HTML, a space between two inline elements renders as a space, so reformatting can visibly change a page. This uses Prettier’s CSS-aware whitespace handling, which respects the display type of each element rather than reflowing everything blindly. Minifying is more conservative still: the contents of pre, textarea, script and style blocks are left exactly as written.

Inline scripts and styles

Script and style blocks are formatted with the same rules Prettier applies to standalone files, so an inline stylesheet is indented properly instead of being treated as opaque text.

Frequently asked questions

Will minifying break my page?
It can, if your layout depends on whitespace between inline elements. Minification here removes comments and collapses runs of whitespace, which is safe for most markup but should be spot-checked on pages using inline-block or inline-flex layouts.
Does it validate HTML?
Only far enough to parse it. Structural mistakes such as an unclosed tag usually surface as a parse error with a line number, but this is not a substitute for a full validator.
Can it handle template syntax?
Handlebars, Jinja and similar templating braces often survive formatting, but they are not understood as syntax and may be moved. Check the output before committing it.

Related tools