HTML, CSS and JS Minifier
How to minify code
- Paste your HTML, CSS or JavaScript. The language is detected, or you can set it yourself.
- The minified version appears below with the size before and after and the percentage saved.
- Copy it or download it as a .min file.
Frequently asked questions
What exactly is removed?
Comments and needless whitespace. In CSS, spaces beside braces, semicolons, commas and colons go, along with the last semicolon in each block. In HTML, runs of whitespace collapse to one space and comments go. In JavaScript, comments and indentation go.
Why does the JavaScript keep its line breaks?
Because removing them can change what the code does. JavaScript inserts semicolons at line ends, so joining two lines that relied on that would break them. Only indentation, blank lines and comments are removed, which is safe on any code.
Will it rename variables like a build tool?
No. Shortening names and rewriting expressions needs a real parser and is the job of a bundler such as esbuild, terser or SWC. This tool is for trimming a file by hand, where the saving is usually 10% to 30%.
Is it safe with strings and regular expressions?
Yes. The scanner tracks quotes, template literals and regular expression literals, so a comment marker inside a string, or a slash inside a regular expression, is left alone.
Why is whitespace between HTML tags kept?
A space between two inline elements is visible on the page, so removing it would push words together. Tick the second box if your markup is all block elements and you want it gone.
Does gzip not do this already?
Mostly, yes. A server compressing with gzip or Brotli already squeezes out repeated whitespace, so minifying first saves far less than the raw byte count suggests. It still helps for inline code, email templates and files served without compression.
Is my code uploaded?
No. The text is processed inside your browser and is never sent anywhere.