LocalExcelTool
Get started

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. 1.Paste your HTML
  2. 2.Pick Format or Minify
  3. 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.

AspectThis toolUpload-based converters
Where the file is processedIn your browser, on this pageOn the vendor's servers, after an upload
Account requiredNoUsually — free tiers ask you to sign in before lifting a limit
Size you can process for freeNo size cap, no run limitA few files per hour, or a ~5–10 MB cap before a paywall
PriceFree. Pro is $9/month, and only buys larger files and AI featuresUsually a subscription — roughly $7–15/month as of November 2026
Works offlineYes, once the page has loadedNo
Time before work starts on a 20 MB fileImmediate — there is nothing to uploadDominated by the upload — about 16 s on a 10 Mbps uplink
What it cannot preserveInvalid input returns the parser error position instead of a repaired fileThe same — the conversion is the same maths

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