Minify a 40 KB script by hand and you will stop after the first comment block. A code minifier does it in one pass: it removes whitespace and comments, shortens local names, and rewrites expressions into shorter forms. This one handles JavaScript (with Terser) and CSS (with csso), and it shows the result next to your input as you type.
Minifying a script, step by step
- Choose JavaScript or CSS at the top. The input box fills with a short sample.
- Paste your own code over it. The output updates about 300 ms after you stop typing.
- Adjust the options. For JavaScript these are Compress code, Mangle variable names, Mangle top-level names, Keep class and function names, Drop console.* calls, Drop debugger statements, the ECMAScript target and the comment handling.
- Read the byte line under the boxes, then press Copy or Download. The file is called
script.min.jsorstyles.min.css.
Which JavaScript switches matter in practice
Mangling shortens the names of local variables and parameters. cartTotal(items, taxRate) becomes something like n(t,o) inside its function. Top-level names are a different matter. They stay untouched by default, because another file or an inline onclick may call them by name. Switch on Mangle top-level names only for code that is fully self-contained, such as a module you bundle yourself.
Dropping console.* removes every call, including the ones that carry a result you use in an expression. Read the output if you rely on logging. Keep class and function names matters when your code reads .name or when stack traces must stay readable.
What csso does to a stylesheet
csso rewrites margin: 0px 0px 0px 0px to margin:0, shortens colors, and removes comments. With Restructure rules on, it also merges rules that share declarations: two selectors with the same color and background-color become one comma-separated rule. That is safe for most files. If your cascade depends on the exact order of rules, switch it off. Custom properties and @media blocks stay in place.
Size numbers and where they stop being exact
The tool counts UTF-8 bytes, not characters, so a file full of accented letters or emoji is measured the way a server sends it. If your browser has CompressionStream, a gzip line shows both sizes as well. Minified code often shrinks less after gzip than before, because gzip already removes repeated whitespace.
Input is limited to 2,000,000 characters. A syntax error in JavaScript shows the line and column. csso, on the other hand, does not report CSS errors: a broken declaration can disappear from the output without a message. HTML is not minified here.
Test before you ship, and what stays in your browser
Minifying changes code. The tool does not promise identical behavior for unusual code, so run your own tests on the minified file. Terser and csso run in this page. The first use loads the library file from this site, which you can see in the network panel. After that, pressing a button sends nothing. Your code is not uploaded, and the tool never executes it.