HTML Formatter

Beautify minified or messy HTML into readable, properly indented markup.

HTML Formatter Runs locally · No sign-up
Output

About HTML Formatter

Hand-edited pages, email templates, and copy-pasted snippets are frequently minified or badly indented, leaving nested elements impossible to follow. This tool re-parses the markup and lays each element on its own line with indentation that matches its depth, so you can finally see where a div closes.

The formatter is tolerant by design: unclosed tags and other mistakes common in real-world HTML are normalized rather than rejected, because strictness would be useless on messy copied code. Inline elements stay on one line, void elements never gain closing tags, and both comments and conditional comments are preserved.

Front-end developers use it to untangle markup received from designers, email developers clean up exported templates before editing them, and anyone inspecting a page's source can prettify the view. It also makes code reviews of HTML changes dramatically easier to follow.

How to Use

  1. Paste minified or messy HTML.
  2. Press Format HTML.
  3. Copy the indented output into your editor.

Example

<div><p>Hello</p><span>World</span></div> <div> <p>Hello</p> <span>World</span> </div>

Each nested element moves to its own line with indentation matching its depth.

FAQ

Will it preserve inline elements on one line?

Yes, common inline elements stay inline so text like <strong>bold</strong> isn't broken across lines.

Does it handle void elements?

Yes, void elements like <img> and <br> are recognized and never given closing tags.

Can it work on messy real-world HTML?

Yes, unclosed tags are tolerated and normalized as best as possible, which covers most copied markup.

Can I format just a fragment of HTML?

Yes. The tool handles partial markup, indenting whatever elements you provide. A fragment is treated as its own document, so no wrapper element is added and the structure you pasted is exactly what you get back.

Are embedded scripts and styles formatted too?

The tool indents the script and style blocks in place, but does not reformat the CSS or JavaScript inside them, so the code stays exactly as written.