Frontend ToolsA little help for every day

Search by name or task, such as JSON or percentage.

Frontend Tools

HTML Minifier with Inline CSS and JS Compression

Minify HTML in your browser: strip comments and spare whitespace, keep pre and textarea content intact, compress inline CSS and JavaScript, and see bytes saved.

View all tools
ResultUpdates as you type

311 bytes → 248 bytes, 20.3% smaller. Content inside pre and textarea is kept as it was.

<nav class="site-nav"><ul><li><a href="/">Home</a></li><li><a href="/about">About us</a> <a href="/blog">Blog</a></li></ul></nav><pre>
  Spaces   in pre are kept
</pre><script>const url="https://example.com";console.log("Hello from "+url);</script>

How to use HTML Minifier with Inline CSS and JS Compression

Paste HTML into the box and the minified version appears beside it as you type. Pick a whitespace mode, choose whether to remove comments and minify style and script blocks, then copy the result.

  1. Paste your HTMLPaste a snippet or a full document. Inline style and script blocks and pre sections are all handled.
  2. Choose whitespace handlingSafe collapses runs of spaces but keeps one between inline elements; Remove all is smaller but can join words.
  3. Check the saving and copyRead the before and after byte counts, test the page in a browser, then copy the minified code.

What the built-in example shows

The sample input is a commented navigation list, a pre block and a short script, 311 bytes in total. Minified with the default settings it drops to 248 bytes, 20.3% smaller. The comment and indentation disappear, block tags such as ul and li sit directly next to each other, and the run of spaces in About us collapses to one. The single space between the About us and Blog links survives, so the two links still render apart. In the script, the // greet comment goes but the // inside the https:// string stays, because the JavaScript is tokenised rather than searched with patterns.

Whitespace modes and what is never touched

Safe mode, the default, turns each run of spaces, tabs and line breaks into a single space and drops it next to block-level tags, so text renders as before. Remove all whitespace between tags also deletes lone spaces between inline elements, which can glue adjacent links or words together. Leave whitespace alone keeps text exactly as written, while comments and inline code are still processed. Content inside pre and textarea is always kept exactly, as are IE conditional comments. JSON-LD scripts are rewritten as compact JSON, and scripts of unknown types, such as templates, are left untouched.

Accuracy and data handling

After adding generated code to a project, test it in the target browsers and responsive sizes. The calculation runs in your current browser; the tool code does not send the input to a processing API.

Often Used Together

Next step

FAQ

Does minifying HTML affect SEO?

No. Only comments and redundant whitespace are removed; tags, attributes and visible text stay the same, so search engines read identical content from a smaller file.

Why are two links stuck together after minifying?

You probably chose Remove all whitespace between tags, which deletes the space between inline elements. Switch back to Safe and one space is kept, so the page looks as it did.

Do I still need to minify HTML if my server uses gzip or Brotli?

The two work together. Compression shrinks the transfer, and removing comments and whitespace makes the source smaller first, although the extra gain on an already compressed site is usually modest.

Is the HTML I paste uploaded?

No. Minifying runs in your browser as you type, and the code you paste is not sent to the server.

More Frontend Tools

Related tools