Start a project

Tool 38 of 57 · Code

HTML Minifier & Beautifier

Tidy messy HTML into neat indentation, or minify it for production, without breaking pre blocks, inline text spacing or scripts.

HTML Minifier & Beautifier at a glanceIllustration: 1, Any HTML; 2, processed in your browser; 3, Indented or minified.HTML Minifier & Beautifier</>1Any HTML3Indented or minified2In yourbrowser
1 Any HTML 2 processed on your device 3 Indented or minified

HTML Minifier & Beautifier

Your HTML

Result

HTML

01

What it does

Minifies or indents HTML, leaving pre, textarea, script and style content exactly as it was.

  • Indent nested elements
  • Collapse whitespace without gluing words together
  • pre, textarea, script and style kept verbatim
  • Comments removed (conditional comments kept)

02

Private by design

Everything happens in your browser. Nothing you type, paste or upload is sent anywhere, and it keeps working offline once the page has loaded.

03

What you get

Minified or indented HTML, with a Copy and a Download button on every result.

  • HTML
  • Minify
  • Format

Why it matters

HTML from CMS exports, email builders and old sites is often a single unreadable line or a mess of inconsistent indentation. Beautifying it makes it possible to find the bit you need to change.

Minifying HTML saves less than minifying CSS or JavaScript, but on large pages it still trims a few kilobytes. The risk is breaking spacing between inline words or inside pre blocks, which this tool is careful to avoid.

How it works

  1. InputHTML markup
  2. In your browserTokenised; pre, script and style left alone
  3. OutputIndented or minified HTML with sizes

Where it fits in a designer's workflow

  1. Plan
  2. Design
  3. Build
  4. Test
  5. Launch
Tidying exported HTML or squeezing a page before launch.

By the numbers

This site's home page as shipped and minifiedAs shipped: 52.4 KB; As shipped, gzipped: 10.5 KB; Minified by this tool: 49.9 KB; Minified by this tool, gzipped: 10.3 KBAs shipped52.4 KBAs shipped, gzipped10.5 KBMinified by this tool49.9 KBMinified by this tool, gzipped10.3 KB
Measured by running this tool's own minifier on leej.uk's index.html at build time: 5% smaller raw, 2% smaller gzipped. The page is already tidy, so the saving is small; pre, textarea, script and style content is never touched.
Show the numbers as a table
VersionBytesGzipped
As shipped53,69210,782
Minified by this tool51,08910,515

How to use it

  1. Paste your HTML.
  2. Choose Minify or Beautify and the options.
  3. Check the result and the size.
  4. Copy or download it.

FAQ

Will minifying change how my page looks?

It shouldn't. Runs of spaces are collapsed to one space, which HTML treats the same, and pre and textarea keep their exact spacing.

Does it fix broken HTML?

No. It keeps your tags as they are. Run broken pages through the W3C validator to find errors.

Does it minify inline CSS and JavaScript?

No, they're kept exactly as written. Use the CSS Minifier for styles.

Are my files uploaded?

No. It all runs in your browser.

Work with me

Want a site that gets these right?

I build fast, accessible websites and web apps that pass these checks from day one. Tell me about your project and I'll reply personally with honest next steps.

All developer tools · Back to leej.uk