Code Minifier
Reduce file size by removing comments, whitespace, and unnecessary characters. Supports JavaScript, CSS, HTML, and JSON.
Remove Comments
All comments are stripped out to reduce file size for production.
Whitespace
Unnecessary spaces, tabs, and newlines are removed while preserving functionality.
Size Stats
Compare original and minified sizes to see your savings percentage.
About the Code Minifier
This code minifier strips comments and whitespace from JavaScript, CSS, HTML and JSON, and reports the before and after size so the saving is visible rather than assumed. Output is a build artefact, not a replacement for your source.
A code minifier removes everything that exists for the reader rather than the machine. Comments, indentation and line breaks affect nothing at runtime but are downloaded by every visitor on every uncached request.
Savings differ by language. CSS and JSON typically drop 20 to 30%, JavaScript can go further because identifiers can be shortened too, and HTML usually gains the least. Gzip then compresses the result again, since minified code is still highly repetitive.
One caution on HTML: whitespace between inline elements renders as a space, so aggressive minification can visibly change spacing in text-heavy markup. Always keep the readable version in source control and treat minified output as a build artefact.
How to use the Code Minifier
- Pick the language. Choose JavaScript, CSS, HTML or JSON.
- Paste your code. Enter the source to compress.
- Minify. Comments and whitespace are stripped.
- Check the saving. Compare the before and after sizes, then copy the output.
Code Minifier features
- JavaScript, CSS, HTML and JSON minification
- Comment removal
- Before and after size comparison
- Preserves pre and textarea content in HTML
- Output is a build artefact, not a source replacement
- Runs entirely in your browser
Frequently asked questions
How much smaller will my file get?
CSS and JSON typically 20 to 30%, JavaScript often more, HTML usually least. Gzip compresses the result further.
Is minifying HTML risky?
Slightly. Whitespace between inline elements renders as a space, so check text-heavy markup after minifying.
Are comments removed?
Yes. Keep the commented version in source control and treat the minified file as a build artefact.
Does minifying change behaviour?
It should not. Only formatting is removed, though HTML inline spacing is the one case worth verifying.
Is my code uploaded?
No. Minification happens entirely in your browser.