How to use it
This HTML beautifier turns minified or inconsistently indented markup into a clean tree with two spaces per level. Block elements start on their own line, while inline elements such as links, strong and span stay inside the sentence they belong to, so the formatting never changes what the page looks like. Embedded <script> and <style> blocks are formatted too, entirely in your browser.
How to use the HTML beautifier
- Paste the HTML you want to read: a full page, an email template or a single component.
- Format it with the "Run tool" button; the Ctrl + Enter shortcut works as well.
- Scan the indentation to understand the structure and spot misplaced closing tags.
- Copy the result back into your editor or download it as a text file.
Formatting rules at a glance
| Content | How it is laid out |
|---|---|
Block elements such as div, ul, section, table | Own line, children indented one level |
Inline elements such as a, em, img | Kept on the same line as surrounding text |
| A block holding only text and inline elements, up to 100 characters | Stays on one line, for example <li><a href="/">Home</a></li> |
| Longer text blocks | Split into opening tag, text and closing tag |
script and style | Formatted as JavaScript and CSS at the right depth |
| JSON-LD structured data | Pretty-printed JSON |
pre and textarea | Preserved exactly |
| Comments and the doctype | Kept, each on its own line |
Whitespace inside tags is tidied as well, so <div class = "card"> becomes <div class="card">, while quoted attribute values are left alone.
A worked example with optional end tags
HTML allows some closing tags to be omitted, and generated markup often does exactly that. Consider <div class="card"><h2>Pricing</h2><p>From <strong>$9</strong> per month</p><ul><li>One site<li>Email support</ul></div>. The beautifier puts <h2>Pricing</h2> and the whole paragraph on single lines at the second level, with <strong>$9</strong> still inside the sentence. The list opens on its own line, and because a new li implicitly closes the previous one, both items sit at the same depth instead of drifting further right. The same rule applies to p, td, tr, option, dt and dd.
Finding structural bugs through indentation
The beautifier never inserts missing tags, but it exposes them. Format <main><article><h2>Title</h2><div class="body"><p>Text</article></main> and </article> follows the word "Text" directly, stepping back three levels at once with no </p> or </div> line in between. That gap is the signature of an unclosed element, here the div. A useful rule of thumb: when the indentation drops by more than one level in a single step, and the skipped elements are not ones with optional end tags such as li, p or td, a tag above was never closed.
Formatting also makes template reviews easier. Beautify two versions of a page with the same rules and paste them into the text diff checker; differences in indentation disappear and only real changes remain.
Where messy HTML comes from
- Minified production pages copied from the browser's page source.
- Email templates built from nested tables, where one stray cell breaks the layout.
- Output from visual editors and page builders with erratic indentation.
- Embed codes for maps, video players or forms pasted from third-party services.
- HTML fragments returned inside JSON fields by an API or headless CMS.
What it will not do
It does not validate markup, add missing end tags, fix incorrect nesting, wrap long lines at a fixed width, reorder attributes or change tag case. Indentation is always two spaces. Those limits are deliberate: every change it makes is one that browsers ignore, so the formatted page renders exactly like the original.
Privacy and related tools
Formatting runs in JavaScript in your browser; the markup is not sent to the server, and the page only increments an anonymous usage counter. When you are ready to ship, the HTML minifier reverses the process. Separate stylesheets and scripts can go through the CSS beautifier and the JavaScript beautifier.