HTML Beautifier & Formatter
Paste minified or messy HTML to beautify with custom indentation, or minify for production
Paste minified or messy HTML, pick your indent size, and hit Beautify to get clean, readable markup in seconds. You can also go the other way — Minify strips all whitespace for a production-ready file. And everything runs in your browser. Nothing gets uploaded.
How It Works
The formatter reads your HTML tag by tag, builds an internal tree of parent-child relationships, then writes everything back with the indent level you chose. Block elements like <div> get their own line. Inline elements like <span> stay put where they belong. It also handles embedded <style> and <script> blocks with their own indentation rules.
Examples
Minified Page Cleanup
Your build tool output a single-line HTML file and you need to track down a layout bug.
<div class="wrap"><header><h1>My Site</h1><nav><a href="/">Home</a><a href="/about">About</a></nav></header><main><p>Hello</p></main></div>
<div class="wrap">
<header>
<h1>My Site</h1>
<nav>
<a href="/">Home</a>
<a href="/about">About</a>
</nav>
</header>
<main>
<p>Hello</p>
</main>
</div>
Nested Email Template
Marketing sent over a table-based layout from Mailchimp. Completely unreadable as-is.
<table><tr><td><table><tr><td style="padding:10px">Content</td></tr></table></td></tr></table>
<table>
<tr>
<td>
<table>
<tr>
<td style="padding:10px">
Content
</td>
</tr>
</table>
</td>
</tr>
</table>
StackOverflow Form Snippet
Copied a quick snippet from an answer. Just needs tidying up before dropping into your project.
<form><label>Name</label><input type="text"><button>Send</button></form>
<form>
<label>Name</label>
<input type="text">
<button>Send</button>
</form>
Who Uses This
Reformatting minified production HTML to hunt down missing closing tags or trace layout bugs.
Cleaning up HTML exported from Figma or Webflow before handing it off to the dev team.
Making sense of deeply nested table layouts that Mailchimp or Constant Contact spit out as one block.
Reading example HTML from tutorials that got copy-pasted without any formatting.
Common Mistakes
Unclosed tags and bad nesting stay broken after formatting. The tool indents what it sees — it doesn't repair structure. Run a validator first if your markup has errors.
All that indentation adds kilobytes of whitespace your visitors download for nothing. Keep beautified code in your source files and hit Minify before deploying.
You format with 2 spaces but the project uses 4. Now every line shows as changed in the PR diff. Check your .editorconfig or linter config first.
Technical Details
- Processing: 100% client-side — nothing leaves your browser
- Max Input: No hard limit; handles files up to several MB
- Indent Options: 2 spaces or 4 spaces
- Line Wrap: 80 chars, 120 chars, or no wrap
- Browser Support: Chrome, Firefox, Safari, Edge
Frequently Asked Questions
What does an HTML beautifier actually do?
It takes minified or messy HTML and reformats it with proper indentation and line breaks. Your code's structure stays the same — only whitespace changes. Think of it like auto-formatting a document, but for markup.
Will beautifying HTML change how my page renders?
No. Browsers ignore extra whitespace in HTML, so added indentation won't affect what visitors see. The one exception: content inside <pre> tags, where whitespace is literal. This formatter leaves <pre> blocks alone.
Can I beautify just a partial snippet instead of a full page?
Absolutely. Paste a full document or a single <div> — both work fine. You don't need <html>, <head>, or <body> wrappers. Whatever fragment you give it gets formatted.
Does it handle CSS and JavaScript inside the HTML?
Yes. Inline style attributes stay on the element's line. Embedded <style> and <script> blocks get their own indentation applied with the right language rules. It won't mangle your CSS or JS.
Should I pick 2-space or 4-space indentation?
Most frontend style guides (Google, Airbnb) recommend 2 spaces for HTML because deeply nested markup stays narrower on screen. If your team already has a standard, match that. Otherwise, 2 spaces is the safer default for web projects.