HTML Formatter
Format and indent messy or minified HTML into clean, readable markup. It runs entirely on your device — nothing is uploaded.
Example
Input
<div><h1>Hi</h1><p>One line</p></div>
Output
<div>
<h1>Hi</h1>
<p>One line</p>
</div>
How it works
Your HTML is parsed and re-printed by Prettier with consistent indentation and line breaks.
Good to know
The HTML Formatter takes minified, copy-pasted, or hand-tangled markup and re-prints it with consistent two-space indentation and sensible line breaks, using the Prettier engine running directly in your browser. It is aimed at developers, students, and anyone who has been handed a wall of single-line HTML — exported template output, a "view source" dump, or a code snippet stripped of whitespace — and needs to actually read or edit it.
Reach for it when you want to inspect the structure of a page, diff two versions of a template without whitespace noise, or clean up markup before pasting it into a tutorial, bug report, or pull request. Because the formatter rebuilds the document from its parsed tree rather than just adding spaces, the output reflects the real nesting of your elements, which makes it easy to spot a tag that closes in the wrong place or an element nested deeper than you expected.
To read the result, follow the indentation: each level of depth is one step further in, so a child element always sits to the right of its parent and siblings line up at the same column. If the output looks structurally surprising — an element jumping out a level, or content collapsing onto one line — that usually points to a real issue in your source, such as an unclosed tag or stray bracket, rather than a formatting quirk.
One practical caveat: formatting is about presentation, not validation, so the tool will happily indent invalid or broken markup and may even fail or produce odd output if a tag is severely malformed. It also normalizes whitespace, which can subtly affect rendering inside whitespace-sensitive elements like <pre> and <textarea>, so review those sections after formatting.
Frequently asked questions
Is my data uploaded anywhere?
No — everything runs in your browser. Your code never leaves your device, so it's safe for private work and runs offline once loaded.
Is this tool free?
Yes, completely free with no sign-up and no limits.
People also ask
What indentation does the HTML Formatter use?
It applies Prettier's default of two-space indentation, nesting each child element one level deeper than its parent. The indentation is consistent throughout the document, so sibling elements always align at the same column.
Does formatting HTML change how the page looks in a browser?
For most markup the rendered result is identical, since browsers ignore insignificant whitespace between tags. The exception is whitespace-sensitive elements such as pre, textarea, and code, where added line breaks or spaces can affect what is displayed.
Can I format minified HTML back into readable code?
Yes. The tool parses the minified markup and re-prints it with line breaks and indentation, which is the reverse of minifying. Note that minification often strips comments and collapses whitespace permanently, so formatting restores readability but not anything that was deleted.
What is the difference between formatting HTML and validating it?
Formatting only changes spacing, indentation, and line breaks to make code readable; it does not check whether the markup follows HTML rules. Validation is a separate step that flags errors like unclosed tags or invalid attributes, which a formatter does not report.
Will the formatter fix broken or unclosed HTML tags?
No. It re-indents the structure it parses but does not repair errors, and badly malformed markup can lead to unexpected output or a parsing failure. Unusual indentation in the result can be a clue that a tag is unclosed or misplaced.
Is there a size limit on how much HTML I can format?
There is no fixed limit set by the tool itself, since everything runs locally in your browser. Very large documents may format more slowly because the work depends on your device's memory and processing power rather than a server.
Does the HTML Formatter work offline?
Once the page and its scripts have loaded in your browser, the formatting runs entirely on your device and continues to work without an internet connection. No network request is made to process your markup.
Related tools