HTML Formatter
This free online HTML formatter turns messy markup into clean, readable code — and can minify it back down for production.
All tools on this site run entirely in your browser locally. No data is uploaded to any server.
Features:
- Beautify: Re-indent HTML into a clear tag hierarchy, with 2, 3 or 4 spaces per level (2 by default)
- Minify: Strip whitespace and line breaks, compressing everything into a single line
- Code folding: Collapse and expand tag blocks to navigate large documents
- Local files: Open an HTML file from your computer, or drag and drop it into the editor
FAQ:
- Q: Do I need to click Format, and why does it read the right pane?
A: No: typing in the left pane reformats into the right pane automatically. Format reads the right pane instead, so you can tidy text you've edited there or expand a minified one-liner back into indented markup. Copy, Minify and Save use the right-hand text too. Typing in the left pane again regenerates the right pane, so manual edits there are overwritten. - Q: Can I change the indentation?
A: Yes. The toolbar offers 2, 3 or 4 spaces (2 by default) and reformats immediately when you switch. The only option under Settings is Line Wrap, which controls how long lines are displayed in the right pane, not the output. - Q: What does Minify change, and can I undo it?
A: It strips HTML comments and empty attributes and collapses whitespace into one line. Click Format to re-indent the result, but removed comments and attributes are gone. - Q: Is inline script and style content left alone?
A: No. Minify runs the JS and CSS minifiers on embedded code as well, not just the whitespace between tags. Use Format if you only want the layout tidied up. - Q: What does the number in the right pane mean?
A: It shows the cursor line and the total line count, for example 3/12 means line 3 of 12. It disappears when the right pane is empty.
Common uses:
- Cleaning up unformatted markup for easier reading and debugging
- Compressing HTML to reduce page size
- Spotting broken tag nesting and other structural issues
- Tidying up HTML snippets copied from webpages or emails