Feedback

Minify JS

Minify JS files and snippets right here: the tool runs terser in your browser, removes whitespace and comments, shortens local names and drops dead code. You see the size before and after, including gzip, and can download the result with a source map.

Your code is processed only in your browser and never uploaded.

Options

From the Solo plan

Minified JavaScript grows again with every release. A performance budget per URL in a plan sets a limit for script size; PerfDelta warns before you reach it and emails you when a page goes over.

Minify JS with terser: whitespace, long names and dead code removed

terser is the JavaScript minifier that webpack 5 uses by default in production mode. It works in two passes. Compression rewrites the code into shorter equivalents: it folds constants, removes unreachable branches and unused functions, and joins statements. Mangling then renames local variables and function parameters to one or two letters. Global names and object properties stay as they are, so code that other scripts call keeps working.

This page runs terser 5.51 in a web worker in your browser. Paste code or choose a .js, .mjs or .cjs file; the result appears below with copy and download buttons.

Minify JS plus gzip: pako shrinks from 216 KB to 14 KB

Measured with this tool's default settings on 27.11.2026: the unminified build of the compression library pako 1.0.11 (dist/pako.js, MIT license) drops from 221,496 to 45,884 bytes, a reduction of 79 percent. The official pako.min.js of the same version is 45,988 bytes. With gzip at level 6 the file goes from 53,441 to 14,124 bytes.

Minification and compression add up: gzip and Brotli find repeated strings, minification removes characters that are not needed at all. The server compression itself is covered in the guide enable text compression.

JS minify options: function names, mangling, ES modules and license comments

Tick "Keep function and class names" if the code reads them at runtime, for example through Function.name or constructor.name; compression and mangling would otherwise remove or shorten them. Dependency injection by parameter name, as in AngularJS 1 without annotations, needs mangling turned off. "ES module" tells terser that the file is a module: import and export are allowed, strict mode applies, and top-level names may be shortened because they are not globals. Leave it off for classic scripts that define globals on purpose.

"Keep license comments" keeps comments that start with /*! or contain @license or @preserve. Many open source licenses, including MIT and BSD, require that the copyright notice stays with copies of the software.

Source map for minified JS: errors point to the original line

With "Create a source map" terser also writes a .map file and adds a sourceMappingURL comment to the minified code. The map names your input file and contains its source text. Upload both files next to each other; DevTools and error tracking tools then show stack traces and breakpoints in the original lines. Because the map contains your original code, only deploy it where that is acceptable.

JS minify errors: terser stops at the first syntax error with line and column

terser only accepts valid JavaScript. On a syntax error the tool shows the line, the column and the line itself. Common causes are TypeScript types, JSX or template placeholders in the file: compile those to plain JavaScript first, then minify.

Minify JS in the build for code that changes often

For a single file or a quick check this tool is enough. For a site that is deployed regularly, minification belongs in the build: webpack minifies with terser in production mode, and most other bundlers ship a minifier of their own. Removing code the page never runs usually saves more than minifying it, see reduce unused JavaScript. Why Lighthouse reports unminified files and how much it counts is explained in the guide on minify CSS and JavaScript.

Other minifiers

Minify JS FAQ: upload, behavior and file size

Is my JavaScript uploaded?

No. terser runs in a web worker in your browser. The code is never sent to a server.

Does minified JS behave exactly like the original?

terser is built to keep the behavior of valid code. Exceptions are code that reads function or class names (use "Keep function and class names"), Function.prototype.toString or the exact source text. Test the minified file before you deploy it.

Is minifying the same as obfuscating?

No. Minifying makes code shorter, not secret. Any code formatter makes minified JavaScript readable again, only the shortened local names are lost.

How large can the code be?

Up to 10 MB, pasted or as a file. Large bundles take a few seconds because terser analyses the whole file; the page stays usable while it works.

More free tools

All free tools →

Third-party licenses

The minifiers use terser (BSD-2-Clause), html-minifier-terser (MIT) and csso (MIT), also for inline CSS. Full license texts: THIRD_PARTY_LICENSES.txt

A free account saves your tests and shows how your values change from one test to the next. Website performance monitoring with field data and alerts starts with the Solo plan.