JavaScript Minifier

Make JavaScript files smaller with Terser, the minifier used by most modern build tools. Remove comments and spaces, shorten variable names and drop unused code, while keeping licence comments if you want.

Your JavaScript

Minified JavaScript

    How to use the JavaScript Minifier

    1. Paste your JavaScript, or use Try an example.
    2. Choose compress, shorter names and whether the code is an ES module.
    3. Copy the minified code or download it as script.min.js.

    Your data stays on your device. This tool runs entirely in your browser. Nothing you type or paste is sent to our server or saved. Read our privacy policy.

    How JavaScript minification works

    This tool uses Terser, the minifier behind most modern build tools. It removes comments and whitespace, renames local variables to short names (totalPrice becomes t) and, with compress on, rewrites code into shorter equivalents and removes code that can never run.

    Typical savings

    OptionWhat it doesTypical saving
    Whitespace and comments onlySafest20–30%
    + Shorter names (mangle)Renames local variables40–50%
    + CompressRewrites and removes dead code50–60%+

    Is it ES module code?

    Turn on “ES module” for files that use import and export. Module code is always in strict mode, which lets Terser shorten even top-level names safely.

    Things to watch

    • Keep the original file for editing; minified code is not meant to be read.
    • If other scripts call your functions by name, check that those global names still work after minifying.
    • Syntax errors stop the minifier; the message shows the line to fix.

    Shrink your styles too with the CSS Minifier. Your code is processed in your browser and never uploaded.

    Frequently asked questions

    Will minified JavaScript still work?

    Yes. Terser rewrites the code into a shorter form that does the same thing. Test the minified file before publishing, especially if other scripts use your global function names; turn off Shorten variable names if they break.

    Why do I get a syntax error?

    The minifier has to understand your code completely, so even a missing bracket stops it. The message shows the line and column. If your code uses import or export, turn on Code is an ES module.

    Is my code uploaded?

    No. Terser runs in your browser, so your code never leaves your device.