Skip to content
AZ Tools

HTML / CSS / JS Minifier

Strip whitespace and comments from HTML, CSS, or JavaScript — see the size saved and copy the result.

Original
234 B
Minified
159 B
Saved
32.1%
Minified
<!doctype html><html lang="en"><head><title>Sample Page</title></head><body><h1>Hello, world!</h1><p>This is a paragraph with multiple lines.</p></body></html>

How to use

  1. Paste your source code.
  2. Pick the language (HTML / CSS / JS).
  3. Toggle whether to strip comments.
  4. Copy the minified output.

About this tool

Show

Shrink HTML, CSS or JavaScript by stripping comments and squeezing out the whitespace a build step would normally remove, with the before and after sizes and the saving shown so you can see whether it was worth it. It is a text-level squeezer rather than a parser, and that shapes what it is good for. Whitespace is collapsed everywhere, including inside pre and textarea elements where spacing is meaningful, so run it on markup without those or restore them afterwards. On JavaScript it only removes comments and spacing — no renaming, no dead-code removal — which makes it handy for an inline snippet or an email template but no substitute for a real bundler on production code. Everything runs locally in your browser.

Frequently asked questions

Is this safe for production?

For small CSS or HTML, yes — the rules are conservative. For JavaScript, prefer a tool like terser or esbuild in your build, since this tool doesn't rename variables, fold constants, or do dead-code elimination.

Why isn't my JS more compressed?

True JS compression needs an AST-based tool. This minifier removes whitespace and comments only — that's already a big win for hand-written snippets but won't match terser's output.

Will it break HTML inside <pre> or <textarea>?

It can — whitespace there is significant. Avoid running the minifier on HTML containing those elements, or replace their contents with a placeholder first.

Are CSS comments important?

Sometimes — license headers in /*! comments by convention are kept by professional minifiers. This tool removes all comments if 'strip comments' is on; for license-preserving output, set it off.

Related tools