Code Minifier (shrink HTML · CSS · JS · JSON)
Remove comments and unnecessary whitespace from HTML, CSS, JS and JSON to cut file size. Paste code or open a file (drag and drop works), then copy the result or download a .min file. Your code is never sent to a server.
Result
- Before
- After
- Saved
- gzip size (estimate)
- –
Estimated transfer size if your server sends it gzip-compressed (uses the browser compressor; shown as – where unsupported).
This tool only removes comments and whitespace. It does not rename variables or rewrite code, so it saves less than terser or esbuild but never changes behavior. Re-test code you ship.
How it works
- All four languages use minifiers built for this site. Strings, regex literals, template literals and url() are left untouched; only comments and whitespace between tokens are removed.
- For JS, whitespace that contains a line break is kept as a single line break, because automatic semicolon insertion (ASI) depends on line breaks.
- For HTML only whitespace between block-level tags is removed; a single space between inline elements stays so words do not run together. <pre> and <textarea> are left as is, and <script> / <style> go through the JS / CSS minifier.
- JSON loses only whitespace outside strings. It is not parsed and re-written, so big integers, 1.0 and unicode escapes stay unchanged.
- Opening a file picks the language from the extension, and downloads are named like app.js → app.min.js.
FAQ
Is my code or file uploaded?
No. Files are only read by the browser and everything runs inside this tab.
Minifying changed how my code behaves.
Only comments and whitespace are removed, but very rare syntax (code where a regex is ambiguous) can go wrong. Please report it, and keep your original meanwhile.
Why are variable names not shortened?
Renaming needs a full parser, and a mistake silently changes behavior. This tool puts safety first. For more savings enable gzip on your server or use a build tool (terser, esbuild).
How should I manage .min files?
Keep the original and deploy only the .min file. Minified code is hard to read and edit.