HTML Formatter

Turn one-line, copy-pasted or minified markup into neatly indented HTML you can actually read — or strip it back down for shipping. Scripts and styles stay untouched.

100% Free No signup Runs in your browser

Format markup

Nothing leaves your device
Paste your markup above, then choose Format or Minify.

How to use this formatter

  1. Paste your HTML — a component from a page, a snippet from an email template, or output that came back minified.
  2. Press Format for two-space indentation based on nesting depth, or Minify to compress it for shipping.
  3. Read the status line: line/character counts before and after, plus a warning if opening and closing tags don't balance.
  4. Copy the result back into your editor.

Useful information

HTML formatting is whitespace surgery: tags, attributes and text stay exactly as they are — only the spacing around them changes. That makes it safe to run on any well-formed markup.

What Format does

Every tag, comment and text node is printed on its own line, indented by how deeply it's nested. Void elements (<br>, <img>…) don't increase the depth, and closing tags step back out.

Protected blocks

Content inside <script>, <style>, <pre> and <textarea> is emitted verbatim — re-indenting JavaScript can break template literals, and re-wrapping <pre> changes what users see. Minify protects them too.

What Minify removes

HTML comments and the whitespace between tags and inside text nodes (collapsing runs to a single space). Rendered output is visually identical, usually 10–30% smaller. Inline onclick attributes and everything else stay as they are.

Working with JSON instead? The JSON Formatter handles that side.

Frequently asked questions

How does the HTML formatter work?

It walks the markup tag by tag — comments, doctypes, elements and text nodes — and reprints them with two-space indentation based on nesting depth. No browser re-serialisation, so your source stays recognisable.

Does it change my markup?

Only whitespace: indentation, blank lines and the spacing between tags. Attribute order, quotes, tag names and text content are untouched, and script, style, pre and textarea contents are preserved exactly.

What does Minify do?

It removes HTML comments and collapses the whitespace between tags and inside text nodes — the rendered page looks identical, but the file is smaller. Protected blocks (script, style, pre, textarea) are left alone.

Does it validate my HTML?

Not a full validation — but after formatting it compares opening and closing tags and warns you when some look unclosed, which catches the most common structural mistakes.

Is my HTML stored anywhere?

No. Formatting runs entirely in your browser — the markup is never sent to a server or saved by Jivora.

Related tools