Code Minifier
Minify CSS or JavaScript by removing comments and extra whitespace.
How to use the Code Minifier
Enter your values and pick a mode if the tool offers one.
Click calculate — results appear instantly, computed in your browser.
Copy the result or save the tool to your favorites.
Frequently asked questions
Comments and unnecessary whitespace and line breaks.
It does basic minification; very complex code with regex literals may need a dedicated build tool.
It should not — only formatting is removed, not logic.
No. Minification runs in your browser.
The tool shows the percentage reduction in size.
About the Code Minifier
This tool minifies CSS and JavaScript by stripping out comments, line breaks, and unnecessary whitespace, producing a compact version that does exactly the same thing in fewer bytes. Smaller code files load faster, which directly improves website performance.
What minification is
Source code is written to be readable by humans, with generous spacing, indentation, descriptive formatting, and comments explaining what each part does. None of that matters to the browser, which only needs the instructions. Minification removes everything that exists purely for human readability, the spaces, the line breaks, the comments, leaving functionally identical code in a fraction of the size. The browser runs the minified version exactly as it would the original.
Why smaller files matter
Every file a web page loads must travel across the network to the visitor's browser, and larger files take longer, especially on mobile connections. Minifying CSS and JavaScript reduces their size, often substantially, so pages load faster. Faster loading improves the experience for visitors, reduces bounce rates, and is also a ranking factor for search engines, which favour quick-loading pages. On a busy site, the bandwidth savings add up meaningfully too.
How it fits into a workflow
The standard practice is to write and maintain code in its full, readable form, then minify it for the live version that visitors actually download. You keep the readable source for editing and debugging, and serve the minified output for speed. This tool is handy for quickly minifying a stylesheet or script by hand, for one-off optimisation, or for understanding how much size a file could shed, without setting up a full build pipeline.
What minification does and does not do
Minification only removes redundant characters; it does not change what your code does, rename things, or restructure logic. More advanced build tools go further by shortening variable names and other transformations, but basic minification is safe and predictable. Because it strips comments and formatting, always minify a copy and keep your original source, since minified code is genuinely hard to read and edit afterward.
Privacy and related tools
Your code is minified entirely in your browser and never uploaded, so proprietary code stays private. To format and validate JSON data see the JSON Formatter & Validator. Minification is instant; paste your CSS or JavaScript and get the compact version straight away.