JavaScript Minifier

JavaScript Minifier compresses your code using Terser, the industry-standard minifier. It removes whitespace and comments, shortens local variable names and applies safe optimisations, producing a much smaller file that behaves exactly like the original.

Because it parses your code into a real syntax tree rather than running text replacements, it never corrupts strings, regular expressions or template literals. Minification runs entirely in your browser.

How to use JavaScript Minifier

  1. 1

    Paste your JavaScript

    Drop in the source you want to compress.

  2. 2

    Click Minify

    Terser parses and compresses the code, then shows the byte savings.

  3. 3

    Copy the minified code

    Grab the compact output for production.

Why a real parser matters

A naive minifier that strips whitespace with regular expressions will eventually break code, because whitespace is meaningful inside strings, template literals and regular expressions, and because automatic semicolon insertion depends on line breaks. Terser avoids all of this by parsing the source into an abstract syntax tree and regenerating it.

That means the minified output is guaranteed to be syntactically valid and behaviourally identical, even for tricky input — which is exactly what you want before shipping code to users.

What minification does

Terser removes comments and whitespace, renames local variables to short identifiers, drops unreachable code and folds simple constant expressions. Together these can shrink a file substantially, cutting download and parse time.

Names that are renamed cannot be recovered later, so keep your original source. To make minified code readable again for inspection, use the JavaScript Beautifier — it will restore formatting, though not the original names.

Frequently asked questions

Does minifying change what my code does?
No. Terser preserves behaviour exactly; it only makes the code smaller by removing slack and shortening local names.
Why is minification a button rather than instant?
Terser parses your full program, which is heavier than the simple text tools, so it runs when you click Minify rather than on every keystroke.
Is my code uploaded?
No. Terser runs entirely in your browser, so your source never leaves your device.

Last updated: