HTML Formatter

Turn minified or messy HTML into readable, consistently indented markup — one tag per line, void elements handled correctly.

Developer Tools Runs in your browser · no upload

Reviewed 17 November 2026 · Free · No account needed

ExecutionYour browserInput never leaves your tab
File retentionNoneNothing is stored
AccountNot requiredNo sign-up, no paywall
PriceFreeNo trial, no usage cap on the tool itself

How to use

  1. Paste minified or messy HTML.
  2. Read the formatted markup as you type.
  3. Copy the result into your editor.

Example

Input: <div><p>Hello</p><br><span>world</span></div>

Output: Nested, indented lines; <br> stays on one level

How it works

The HTML is parsed and re-printed with consistent indentation, so nested elements become readable. The structure and content are unchanged — only whitespace and line breaks are adjusted.

The markup is tokenised tag by tag — quoted attribute values and raw blocks (script, style, pre, textarea) are kept intact, so a > inside an attribute never ends a tag — then re-printed one tag per line with 2-space indentation per nesting level. Void elements (br, img, input and friends) and self-closing tags do not open a level.

Worked example

<div><p>Hello</p><br><span>world</span></div> becomes nested, indented lines with <br> sitting at the same level as its neighbours.

Edge cases to know

  • Inline text is placed on its own line by design, so short sentences gain line breaks.
  • Contents of script, style, pre and textarea are kept as one block but re-indented like any text node.
  • Tag soup is formatted as it stands — malformed nesting is not repaired.

Limits & compatibility

  • Inline text flows are split onto their own lines by design.
  • pre/script contents are re-indented like any text node.
  • Tag soup is formatted as-is — malformed nesting is not repaired.

Privacy

Your markup never leaves the browser. There is no server call, no storage and no logging of content.

Related tools

FAQ

Questions about HTML Formatter

What does the formatter change about my markup?

Layout only: every tag moves onto its own line and nested elements are indented, while the tags and text themselves are untouched. Void elements such as br and img stay on one level, and comments and doctypes do not open a nesting level. The result is markup you can actually read and diff.

Will it repair broken or malformed HTML?

No — tag soup is formatted as it stands, and malformed nesting is not repaired. The tokenizer is quote-aware, so a > inside a quoted attribute value does not end the tag, but unclosed elements stay unclosed in the output. Fix the structure first if the source is genuinely broken.

How are pre and script blocks treated?

Their contents are re-indented like any text node, so whitespace inside them is normalised rather than preserved byte-for-byte — worth knowing when exact spacing inside a pre block matters. Inline text flows are also split onto their own lines by design; the goal is readable output, not a byte-identical reconstruction of your file.