JavaScript Minifier – Terser in Your Browser

Paste JavaScript or drop .js and .mjs files to minify them with Terser, the minifier used by most JavaScript build tools. Choose a Safe, Balanced or Max preset, keep /*! license */ comments, create a source map and compare the original with the result in a diff view. The tool also measures gzip and brotli sizes, processes several files at once and downloads them as a ZIP. Everything runs in a background worker in your browser; your code is never uploaded.

Your code

Paste code, or drop files here. Engines load only when you press the button.

Preset

Safe makes only changes that can't alter behaviour; Max squeezes harder (e.g. top-level mangling for modules).

Result

Files

.js .mjs .css .html .htm .svg .json — several at once for a batch
Engines and licenses

This tool uses these open-source engines, loaded only when needed:

100% in your browser: your code is processed on this device and never uploaded.

How to use the JavaScript minifier

  1. Paste your code or drop one or more .js, .mjs or .cjs files onto the page.
  2. Choose a preset. Balanced suits most code; Safe keeps function and class names; Max squeezes harder.
  3. Set the options: keep license comments (on by default), mark the code as an ES module, keep names, or create a source map.
  4. Press Minify. The first run loads the Terser engine in the background; later runs are instant.
  5. Copy or download the result, compare it with the original in the diff view, or measure gzip and brotli sizes.

How it works

Terser parses your code into a syntax tree, then rewrites it: removing whitespace and comments, shortening local variable names (mangling), folding constants, dropping unreachable code and simplifying expressions. It prints the tree back out as compact JavaScript.

Preset What it does
Safe One compression pass; keeps function and class names; no unsafe transforms
Balanced Two compression passes; mangles local names
Max Three passes; also mangles top-level names when the code is an ES module

The work runs in a Web Worker, so even large files don’t freeze the page. A 30-second time limit and a Cancel button stop a job that runs too long.

Worked examples

  • A small utility module of 1.2 KB with comments and descriptive names typically shrinks to well under half its size, and its /*! … MIT */ notice stays at the top.
  • Minifying twice gives the same or a smaller result, never a larger one, so it’s safe to re-run on already minified code.
  • A syntax error such as a missing value after = is reported with its line and column, so you can find it quickly.

Tips and common mistakes

  • Test the output. Minifiers are reliable, but code that reads its own function names (for example some dependency-injection libraries) needs Keep names.
  • Don’t strip licenses you’re required to keep. Leave Keep license comments on for third-party code.
  • Serve with compression. Minification and gzip or brotli work together; compression usually saves more than minification alone.
  • Keep the source. Minified code isn’t meant to be edited. Keep the original under version control and minify again after changes.

Why use this minifier

It runs entirely in your browser with a well-known engine, explains its trade-offs, shows real gzip and brotli numbers, handles batches with a ZIP download and supports source maps, all with an accessible, keyboard-friendly interface and no ads inside the editor.

Frequently asked questions

Is my code uploaded to a server?

No. The minifier runs in a Web Worker inside your browser. The engine is downloaded once when you first press Minify, and your code never leaves your device.

Will minifying change how my code behaves?

Not with the Safe and Balanced presets, which only apply transformations that keep behaviour the same. Max also mangles top-level names in ES modules, so use it only for code that isn't accessed by name from outside, and always test the result.

Why are some comments kept?

Comments starting with /*! or containing @license or @preserve are kept by default, because many open-source licenses require the notice to stay with the code. Turn off Keep license comments to remove them.

What is a source map for?

A source map lets browser developer tools show your original code when you debug the minified file. Download the .map file and serve it next to the minified script.

How big a file can it handle?

Files up to 50 MB. It warns above 2 MB and asks before processing more than 10 MB. Work happens in a background thread, so the page stays responsive, and you can cancel at any time.

Should I use this instead of my build tool?

For production sites, minify in your build (Vite, webpack, Rollup or esbuild) so it happens on every deploy. This tool is ideal for one-off scripts, snippets, bookmarklets and checking how much a file can shrink.

Sources