HTML Formatter

Paste HTML and read it. Each tag goes on its own line with the indentation its nesting deserves — the fastest way to find the div that was never closed.

The code never leaves this page: formatting happens in your browser.

How to use

  1. Paste the HTML into the first box.
  2. Choose the indent: two spaces, four, or a tab.
  3. Copy the result, or press «Minify» to squeeze it back down.

Good to know

What is left alone on purpose

Inside pre and textarea, every space and line break is part of the page — reindenting them changes what the visitor sees. Script and style are not markup at all. The formatter carries those blocks across untouched and only shifts them as a whole, so a formatted file still behaves exactly like the original.

Reading nesting instead of guessing it

Void elements such as img, br and input never close, so a formatter that indents after every opening tag drifts deeper and deeper down the page. Here they are recognised and the indentation stays level, which means an unexpected indent is a genuine sign of an unclosed tag rather than an artefact of the tool.

Frequently asked questions

Does it validate my HTML?

No. It formats what you give it and does not change the markup. An unclosed tag will show up as unexpected indentation, but no error list is produced.

Is my code sent to a server?

No. Formatting happens on the page, so internal templates and pages behind a login stay on your machine.

Can it handle a whole page?

Yes, up to about five megabytes of markup. Beyond that the browser struggles with displaying the result rather than with formatting it.

What happens to comments?

They are kept and placed on their own line. Conditional comments are preserved as well, since they carry markup for old browsers.

Related tools