CSS / JS Minifier
Strip comments and whitespace from CSS or JavaScript with auto-detect, byte stats, and copy/download.
What this does
- CSS — strips /* comments */, collapses whitespace, removes trailing semicolons, tightens punctuation.
- JavaScript — strips // line and /* block */ comments, collapses whitespace, tightens braces and parens. Preserves string and template literals.
Note: this is a safe regex minifier — no variable renaming (mangling) and no dead-code elimination. Use Terser / esbuild in your build pipeline for production-grade compression.
About this tool
CSS / JS Minifier removes everything the browser does not need: comments, redundant whitespace, trailing semicolons, and (for CSS) optional units after zero. Paste your file or drop it onto the page; the tool auto-detects whether you handed it CSS or JavaScript and applies the appropriate ruleset. The original and minified sizes are shown side by side with the percentage saved.
For CSS we follow a conservative rule set — safe across all browsers, no specificity changes, no shorthand rewrites that could change cascade behaviour. For JavaScript the minifier strips comments and collapses whitespace but does not rename variables or mangle identifiers (that would require a parser and risks breaking eval / dynamic property access). For aggressive minification (terser, esbuild, swc) use a build-time tool; this is the right tool for quick "make this smaller before pasting it into an email" tasks.
When to use this tool
- Pre-deploy quick win. A small inline
<style>or<script>that does not go through your bundler still benefits from minification. - Email and AMP templates. Inline CSS hits size limits; stripping whitespace can save 30–40%.
- Copy-pasting into config. Long JS snippets in YAML or JSON config files become much more readable when minified.
- Verifying byte savings before committing to a build-tool change.
What we deliberately do not do
No variable renaming, no dead-code elimination, no expression rewriting. These changes can break code that relies on identifier names (debug, monkey-patching, dynamicthis), and the safety guarantees require a full AST-aware parser. For production builds use terser or esbuild; the savings are larger but the safety surface is much wider. This tool gives you the easy 50% with zero risk.
Frequently asked questions
How much smaller will my file be?
Does it work on TypeScript?
tsc, esbuild, swc) and minify the output. For type-annotated source, a TS-aware tool like esbuild or swc does both type-stripping and minification in one pass and is the right choice.
Will minified CSS break my layout?
Does this work for inline source maps?
//# sourceMappingURL= comment is a comment and goes away). For production you usually want to generate a separate .map file alongside the minified output, served conditionally. Our tool does not generate source maps — that requires a full parser and is the responsibility of a build pipeline. Use esbuild / terser for that workflow.