HTML Formatter
Beautify HTML with clean indentation, or minify it.
What is HTML Formatter
The HTML Formatter beautifies HTML with 2-space indentation or minifies it by stripping extra whitespace and comments. Script and style block contents are preserved untouched. Everything runs locally in your browser.
🔒 Everything runs in your browser. Nothing is uploaded.
What this tool actually does with your file
- Where it runs
- In your browser, on this page
- Upload
- None — the file never leaves your device
- Offline
- Works with the network disconnected
Format or minify, with different risks
Format mode re-indents by tag depth and puts attributes on the opening tag line. Minify mode removes whitespace between tags and collapses runs inside text. The input limit is 2 MB, which is roughly a large single page and well beyond anything hand-edited.
Minifying HTML is riskier than minifying JSON, because in HTML whitespace is sometimes content. Inline elements separated by a space — <b>a</b> <i>b</i> — rely on that space to render apart; removing it joins the words. Block-level structures are safe, inline ones are not.
Content that must not be reindented
<pre>, <textarea> and <script> hold whitespace-sensitive content. Re-indenting inside <pre> changes how code samples render; collapsing whitespace inside <textarea> changes the default value the user sees. A formatter that treats them like ordinary elements quietly alters the page.
Inline SVG has the same character: an extra space between <text> and <tspan> can shift baseline alignment. For SVG, prefer formatting the file as XML and checking the rendering afterwards.
The check that catches everything
Render both versions and compare screenshots, or at minimum diff the extracted text content. A byte diff will show hundreds of changes that do not matter; a text-content diff shows only the ones that do.
Also remember that formatted HTML and well-formed HTML are different claims. Unclosed <p> and <li> tags are legal in HTML5 and a strict XML-style formatter will either reject them or insert closing tags that change the DOM tree.
How to use
- 1.Paste your HTML
- 2.Pick Format or Minify
- 3.Run and copy the result
How this compares
There are three ways to do this conversion: in the browser (this page), through a server-side converter, or with a desktop app. The useful difference is not speed — it is where your file goes and how far the free tier actually reaches.
| Aspect | This tool | Upload-based converters | Desktop software |
|---|---|---|---|
| Where the file is processed | In your browser, on this page | On the vendor's servers, after an upload | On your own machine, after installing an app |
| Account required | No | Usually — free tiers ask you to sign in before lifting a limit | No, though a licence may be needed |
| Size you can process for free | No size cap, no run limit | A few files per hour, or a ~5–10 MB cap before a paywall | Whatever your disk and RAM allow |
| Price | Free. Pro is $9/month, and only buys larger files and AI features | Usually a subscription — roughly $7–15/month as of November 2026 | A one-off licence, or a subscription |
| Works offline | Yes, once the page has loaded | No | Yes |
| Time before work starts on a 20 MB file | Immediate — there is nothing to upload | Dominated by the upload — about 16 s on a 10 Mbps uplink | Just the app launch |
| What it cannot preserve | Invalid input returns the parser error position instead of a repaired file | The same — the conversion is the same maths | The same, though some desktop apps re-render styles more faithfully |
Server-side converters are genuinely better at some things: very large files, sharing results with a team, keeping a conversion history, and automating batches from a script. For the case in front of you — one file, one format change, right now — they mostly add an upload wait and a sign-up form.
Frequently asked questions
Is script/style content safe?
Yes — both formatting and minifying keep <script> and <style> contents exactly as they are.
What does minify remove?
Only HTML comments (IE conditional comments are kept) and whitespace between tags. Attribute values are untouched.
What this kind of conversion cannot keep
Formatters parse the input into a tree and print it back with consistent indentation. If the input is invalid, you get the parser's error position instead of a silently mangled file — malformed JSON stays malformed rather than being «repaired» into something that is no longer yours.
More in Format
On this page
- What is HTML Formatter
- What it does with your file
- How it actually behaves
- How to use it
- How this compares
- FAQ
Excel formula reference
29 functions with syntax, arguments and a table you can retype.
Browse the list →