Code Minifier

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

  1. Select the language — Choose CSS, JavaScript, or HTML from the language selector.
  2. Paste your code — Copy your source code into the input field. The tool handles any valid code in the selected language.
  3. 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.
  4. 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.

FileVersionRawgzipBrotli
Bootstrap 5.3.3 CSSOriginal281,04632,92924,501
This tool232,261 (−17.4%)30,430 (−7.6%)22,536
clean-css (level 1)232,75730,59722,750
jQuery 3.7.1Original285,31483,69769,545
This tool141,154 (−50.5%)40,001 (−52.2%)35,223
terser, compress + mangle87,282 (−69.4%)30,421 (−63.7%)27,541
An HTML page (our About page)Original29,5677,4786,093
This tool25,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.

Frequently Asked Questions

What is code minification?
Removing unnecessary characters (whitespace, comments, line breaks) without changing functionality. Reduces file size and improves page load speed.
Should I minify CSS and JavaScript?
Yes, for production. In our test this tool cut Bootstrap's CSS by 17% and jQuery by 51% before compression (8% and 52% after gzip). For JavaScript, a build-step minifier that also renames variables, such as terser, saves more: about 24% more gzipped bytes on jQuery. Keep the readable originals for development.
Minification vs compression?
Minification removes characters the code does not need; compression (gzip or Brotli) encodes the bytes for transfer and is undone by the browser. They stack: minify first, then let the server compress. In our tests the combination cut jQuery from 285 KB to 40 KB gzipped (35 KB with Brotli), but compression alone already did most of the work for CSS.
What is the difference between minification and compression?+
Minification removes characters the code does not need (whitespace and comments) to produce smaller but still valid code; this minifier does not rename variables. Compression (like Gzip or Brotli) is a server-level process that compresses the file's bytes for transfer. They work together — minify your code first, then serve it with compression enabled.
Does minification affect performance?+
Yes, positively. Smaller file sizes mean faster downloads, reduced bandwidth costs, and quicker parse times. For JavaScript, minification can significantly reduce parse and compile time on slower devices.
Can minified code be reversed?+
Minification is partially reversible — code beautifiers can restore formatting and whitespace, but they cannot recover original variable names, comments, or documentation. This is called prettifying or beautifying, and our Code Beautifier tool can help.

📖 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

Privacy Policy · Terms of Service