HTML Formatter
Get readable, consistently indented HTML from minified or one-line markup.
- Runs in your browser
- No uploads
- No account
Loading your browser tool…
What HTML Formatter does
Minified templates, email HTML and markup copied from browser dev tools often arrive as one long line. Paste it here and each block element moves onto its own line, indented under its parent, so you can see the structure, review a diff or spot where nesting goes wrong.
Short elements, such as a list item holding one link, stay on a single line, and inline tags inside a paragraph stay in the flow of the text. Pick 2 spaces, 4 spaces or Tab under Indent with to match your project.
Example
Input
<nav><ul><li><a href="/">Home</a></li><li><a href="/docs/">Docs</a></li></ul></nav><p>Hi <em>there</em></p>
Result
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/docs/">Docs</a></li>
</ul>
</nav>
<p>Hi <em>there</em></p>The nav and ul get their own lines, while each list item and the paragraph stay on one line because they contain only inline content.
How to use HTML Formatter
- Paste HTML into the HTML box, or click Open file.
- Choose 2 spaces, 4 spaces or Tab under Indent with.
- Click Copy, or Download .html.
Good to know
- It formats but doesn't validate. Missing closing tags aren't reported; they show up as unexpected nesting in the indented result.
- Runs of spaces and line breaks inside ordinary text are collapsed to single spaces, the way a browser displays them.
- There is no minify option. To shrink HTML for production, use your build tool's minifier.
- To also strip styles, classes or unsafe tags, use the HTML Cleaner instead.
Questions about HTML Formatter
How do I format HTML online?
Paste the HTML into the box and the formatted version appears straight away. Choose your indentation, then copy it or download it as an .html file.
Can formatting HTML change how the page looks?
Rarely. Browsers ignore whitespace between block elements. The exception is inline or inline-block elements placed side by side, where a new line between them can add a small visible gap.
Should I indent HTML with 2 or 4 spaces?
Two spaces is the most common choice for HTML, because markup nests deeply and lines get long fast. Four spaces or tabs are fine if your project already uses them; consistency matters more than the number.
Can it format HTML email templates?
Yes. Table-heavy email markup is much easier to follow with each table, row and cell on its own line, and the inline styles email clients rely on are kept as written.