CSS and JavaScript Minifier

Original
–
gzip –
Minified
–
gzip –
Saved
–
gzip –

JavaScript

Minified


      
Your result shows up here.

About the CSS and JavaScript Minifier

Minifying removes everything a browser does not need from a stylesheet or script: comments, spaces, line breaks and long names. The code behaves the same but is smaller, so pages load faster. This tool minifies CSS and JavaScript in one place and shows the size before and after, the percentage saved and the gzip size, which is closer to what visitors actually download.

JavaScript is minified with Terser and CSS with CSSO. You can turn compression and name mangling on or off, keep license comments, and treat the code as an ES module. To read code that someone else minified, switch to Beautify and choose the indentation. Everything runs in your browser in a background worker, so large files do not freeze the page and nothing is uploaded.

How to minify CSS or JavaScript

  1. Choose CSS or JavaScript and select Minify.
  2. Paste your code or upload a .css or .js file.
  3. Set the options and fix any error shown with its line and column.
  4. Check the size saved, then copy the result or download it as a .min.css or .min.js file.

Frequently asked questions

How do I minify CSS or JavaScript?

Choose CSS or JavaScript, make sure Minify is selected, then paste your code or upload a file. The minified result appears as you type, with the size saved. Copy it or download it as a .min.css or .min.js file.

What do the JavaScript options do?

Compress rewrites code into shorter forms and removes dead code. Mangle names shortens local variable and function names. Mangle top-level names also shortens names declared at the top of the file, which is only safe when other scripts do not use them. ES module treats the code as a module, which allows import and export.

How do I beautify or unminify code?

Select Beautify to add line breaks and indentation to minified CSS or JavaScript. Pick 2 spaces, 4 spaces or a tab. Beautifying cannot bring back original variable names or comments that were removed.

What is the gzip size?

Most servers send text files compressed with gzip. The gzip size is how large your code is after that compression, which is closer to what visitors download than the raw size. The tool shows it for the original and for the result.

Why do I get an error with a line and column?

The code has a syntax problem, such as a missing bracket or a stray character. The tool shows the line and column of the first problem and a Go to error button that selects it. Fix it and the result appears.

Which libraries does it use?

JavaScript is minified with Terser and CSS with CSSO. Beautifying uses js-beautify. All three are open source and are served from this site.

Is my code uploaded anywhere?

No. The work runs in your browser, in a background worker, and nothing leaves your device.