DataToolsLab
Code Formatter Tools

HTML Minifier

Strip whitespace, comments and optional attributes from HTML and see exactly how many bytes that saves.

Loading tool…

What is HTML Minifier?

An HTML minifier that shrinks markup without changing what the browser renders. It removes the whitespace that carries no meaning, deletes comments and redundant attributes, and reports the byte savings.

How it works

Each token is re-emitted with the least whitespace the HTML grammar allows. Whitespace between inline elements is kept because it is rendered; whitespace inside <pre> and <textarea> is kept because it is the content; <script> bodies are optionally run through the ASI-safe JavaScript minifier, and comments are removed unless they are conditional comments for old IE.

  1. Paste the source. Drop in code, a stylesheet, a query or a selector list. Everything is read locally — the page never uploads what you paste.
  2. Choose the options. Indent width, quote style, keyword case or target browsers. The result updates as you change them, so you can see the effect immediately.
  3. Copy or download. Copy the result to the clipboard or download it as a file. Reset clears the form and returns every option to its default.

Examples

A minified bundle → readable code

Beautifying a 40 KB one-line stylesheet or script turns it into something reviewable, without altering a single token of the program itself.

A query moved between databases

MySQL's backticks, AUTO_INCREMENT and LIMIT 10, 20 become PostgreSQL's double quotes, identity columns and OFFSET — with a list of what still needs a human.

A stylesheet that only breaks in Safari

backdrop-filter, user-select and position: sticky need -webkit- prefixes for older Safari, which the CSS Autoprefixer adds for exactly the targets you tick.

Common mistakes

Expecting a formatter to fix invalid code

Formatting is whitespace and quoting. A missing brace, an unclosed tag or an unquoted variable survives the round trip and is reported instead — check the findings list.

Minifying without running the tests afterwards

Even a safe, non-mangling minifier can expose an existing automatic-semicolon-insertion bug. The JavaScript Minifier keeps the newlines that matter, but re-run your tests before shipping.

Treating a rewritten query as verified

The SQL Dialect Converter translates the syntax it can prove; data types, casts and function differences are listed for review, not guessed. Run the converted query against a real database.

Renaming or reformatting generated files

Regenerating a formatter's output is a no-op only if the formatter is the same one that produced it. Keep generated code out of the round trip and format the source it came from.

Frequently asked questions

Will minifying break my inline scripts?

The script bodies are minified with the same pass as the JavaScript Minifier, which keeps a newline after return/throw/break/continue and before a token that could continue the previous statement. Turn the option off if your script relies on unusual formatting, and always re-run your tests.

Why is my prefix still there after minifying?

Only attributes that restate the default are dropped — type="text/javascript", type="text/css", method="get" on forms. Vendor prefixes are declarations, not attributes, so nothing in the markup removes them.

How much smaller will it get?

Typically 10–25% for hand-written markup, mostly from indentation and comments. If you need more, the real wins are elsewhere: images, fonts and JavaScript bundles.

Online