Code Minifier
Compress and minify JS, CSS, and HTML files to save space.
Shrink code by removing comments and whitespace
Code Minifier compresses JavaScript, CSS and HTML by deleting comments and collapsing the spaces, tabs and line breaks that humans need but browsers do not. Smaller files download faster, which matters for page speed on slow connections and for snippets that must fit into a length-limited field. The tool works in the browser page and gives you the before and after sizes so you can see what was saved.
Minifying a snippet
- Paste your formatted code into the Input Data box. Sample loads a short CSS rule, and Clear empties the box.
- Press Process Now. If the box is empty you get an error asking for code.
- Read the summary row: Original size, Minified size and Saved percentage. The sizes are counts of characters.
- Use Copy to grab the compressed text or Download to save it as result.txt.
There is no language selector. The same set of rules is applied to whatever you paste.
What it removes
- Block comments between /* and */.
- Line comments starting with // when they end with a line break.
- Spaces around braces, colons, semicolons, commas, greater-than signs and opening square brackets.
- Line breaks and tabs, which become single spaces, followed by a final collapse of repeated spaces.
Good uses
- Compressing a small CSS block for an inline style tag.
- Shrinking a bookmarklet or embed snippet to fit a character limit.
- Measuring roughly how much whitespace and commenting a stylesheet carries.
- Preparing a quick one-line version of an HTML fragment for a template string.
Read this before deploying
This is a lightweight text-based minifier and does not parse your code, rename variables or drop the final semicolon in a rule. That has consequences. Because line breaks turn into spaces, JavaScript that relies on automatic semicolon insertion, meaning statements without semicolons, can break. A double slash inside a string or URL followed by a line break may be mistaken for a comment, which is a known risk noted in the tool's own code. Whitespace around a greater-than sign is removed in HTML too, which can join inline text that needed a space. Always test the result, and use a full build-step minifier for production bundles.
Related Articles
- JavaScript Minification: What It Is and Why It Matters
- Page Speed: Why It Matters and How to Improve It
- Core Web Vitals Explained in Plain Englis
Related Tools