The Util Box

HTML Beautifier

Free online html beautifier for developers. Format and beautify HTML code. Fast and private.

Formatted
Paste HTML above

Embed this tool

Copy and paste the code below into your website to embed this tool for free. An attribution link to The Util Box is required.

<iframe src="https://www.theutilbox.org/embed/html-formatter" width="600" height="500" frameborder="0" style="border: none; max-width: 100%;" title="Free HTML Beautifier tool from The Util Box"></iframe>
<!-- Free tool by The Util Box — https://www.theutilbox.org/tools/html-formatter -->
<a href="https://www.theutilbox.org/tools/html-formatter">HTML Beautifier by The Util Box</a>

Frequently Asked Questions about HTML Beautifier

HTML Formatter — Re-indent Flattened Markup

This HTML formatter takes markup that has been flattened onto one line and puts it back into a readable, indented shape. Paste it in and the tags come out nested with two spaces per level.

It is what you want when you have received minified HTML from a template or an API and need to read it, or when a long single-line file needs to be made navigable.

How the Indentation Is Decided

The markup is split wherever one tag is followed by another, and each piece is placed at the current depth. A closing tag reduces the depth before it is written; an opening tag increases it afterwards. Void elements and self-closing tags do not increase the depth, so they stay at the level of their parent.

Comments and the doctype are left at the left margin.

Honest Limits

  • The split is textual, not structural. A < inside a script, style or textarea block will be read as the start of a tag, and the indentation goes wrong from that point on.
  • Inline elements are treated as block-level, so a <span> inside a paragraph starts a new indentation level even though it does not really.
  • Attributes are left exactly as they are, so single-quoted values and original spacing survive.
  • The output is not guaranteed to be valid HTML. It is the same markup, re-indented — the formatter does not check tag balance or add anything that was missing.

Related Developer Tools

The formatting runs entirely in your browser — your HTML is never uploaded.