What Is Code Minification?
Code minification strips unnecessary characters from source code — whitespace, line breaks, comments, and redundant syntax — without changing how the code executes. The result is a smaller file that downloads faster, improving page load times and Core Web Vitals scores. This tool minifies CSS, JavaScript, and HTML.
Why Minify?
Every kilobyte the browser has to download and parse delays the page. How much minifying saves depends on the language: in our test below it cut a large CSS file by 17% and a large JavaScript library by 51% before compression. Once gzip or Brotli compression is applied, the extra saving shrinks, which is why the transfer size, not the raw size, is the number to watch. Lighthouse, the engine behind PageSpeed Insights, flags unminified CSS and JavaScript as opportunities.
How to Use This Code Minifier
- Select the language — Choose CSS, JavaScript, or HTML from the language selector.
- Paste your code — Copy your source code into the input field. The tool handles any valid code in the selected language.
- Read the output — It updates as you type. The tool strips whitespace and comments; for CSS it also shortens hex colors and drops units from zero values. Strings, template literals, regex literals and the contents of <pre> and <textarea> are left untouched, and line breaks stay wherever JavaScript's automatic semicolon insertion depends on them. Variable names are not renamed.
- Copy the result — Click Copy to grab the minified output. Check the size reduction percentage to see how much you saved.
Worked example: three real files, against the standard minifiers
We ran this tool on three real files in Chromium on October 12, 2026, then compared the results with the minifiers most build tools use: clean-css 5.3.3 for CSS, terser 5.31.6 for JavaScript and html-minifier-terser 7.2.0 for HTML. All sizes are in bytes. The gzip column is level 9 and Brotli is quality 11, which is what a CDN typically sends over the wire.
| File | Version | Raw | gzip | Brotli |
|---|---|---|---|---|
| Bootstrap 5.3.3 CSS | Original | 281,046 | 32,929 | 24,501 |
| This tool | 232,261 (−17.4%) | 30,430 (−7.6%) | 22,536 | |
| clean-css (level 1) | 232,757 | 30,597 | 22,750 | |
| jQuery 3.7.1 | Original | 285,314 | 83,697 | 69,545 |
| This tool | 141,154 (−50.5%) | 40,001 (−52.2%) | 35,223 | |
| terser, compress + mangle | 87,282 (−69.4%) | 30,421 (−63.7%) | 27,541 | |
| An HTML page (our About page) | Original | 29,567 | 7,478 | 6,093 |
| This tool | 25,644 (−13.3%) | 7,052 (−5.7%) | 5,775 |
For CSS and HTML, this tool lands within about 0.5% of the established minifiers. Its Bootstrap output was even slightly smaller than both clean-css and Bootstrap's own bootstrap.min.css (232,803 bytes). The output stayed valid: the CSS parsed without errors, and the minified jQuery passed node --check. The second thing the table shows is how much compression erodes the gain. Once gzip is on, minifying Bootstrap saves only 7.6% of the bytes actually transferred, because gzip already squeezes out most of the repeated whitespace.
JavaScript is where the gap opens up. This tool removes whitespace and comments but does not rename variables, so its jQuery output (141,154 bytes) is close to terser with renaming and compression switched off (139,464). Terser's full mode renames local variables and rewrites expressions, and that cuts the gzipped transfer by another 24% (40,001 to 30,421 bytes). It matches jQuery's official jquery.min.js (87,533 bytes raw). For a quick one-off file, or for code you need to stay readable enough to debug, this tool is fine. For a production bundle, let a build-step minifier with mangling handle the JavaScript.
Lighthouse, the engine behind PageSpeed Insights, still has "Minify CSS" and "Minify JavaScript" audits. Its guidance makes the same point: minification is a build-step job, run every time you deploy, rather than something you paste by hand.
Sources
Checked on .
Frequently Asked Questions
📖 Learn More
Related Article The Complete Guide to Code Formatting and Minification → Related Article How to Minify CSS & JavaScript →Built by Derek Giordano · Part of Ultimate Design Tools