Loading tool…
Setting up your workspace on this device.
Format HTML code.
Loading tool…
Setting up your workspace on this device.
Advertisement
HTML Formatter turns messy or minified HTML into neatly indented, readable markup. In Format mode it uses Prettier’s HTML formatter with a choice of 2 or 4 spaces; switch to Minify to collapse the whitespace between tags and, with Remove comments ticked, strip HTML comments as well. Paste a full page or just a fragment: the output updates after each edit, and a sandboxed preview underneath shows how the markup renders. Copy output puts the result on your clipboard. Formatting runs in your browser, so templates and snippets stay on your device.
Paste your HTML
Add a full document or a fragment to the HTML source box, or press Load sample to try it out.
Choose Format or Minify
Pick 2 or 4 spaces for formatting, or decide whether to tick Remove comments when minifying.
Copy the result
Check the live preview, then press Copy output.
Paste it into the source box with Format mode selected. The markup is re-indented automatically with 2 or 4 spaces, so the nesting of elements is easy to follow.
It should not. The formatter uses CSS-aware whitespace handling, so it avoids adding spaces where they would show between inline elements such as links and spans. The live preview lets you check.
Minify removes line breaks and the whitespace between tags, and can strip comments, giving smaller markup for embedding or sending. Keep the formatted version for editing, as minified HTML is hard to read.
The formatter has to parse your markup first, so problems such as a mismatched closing tag stop it. It shows the parser’s message instead of output; fix the spot it points to and the result updates.
Yes. HTML Formatter is completely free, with no account, no paywall, and no usage limits.
No. HTML Formatter works instantly in any modern web browser — there is no software to install, no extension, and no sign-up.