JavaScript Minifier
Shrink JavaScript for production with Terser, in your browser, with a source map.
Terser does not transpile: the target only limits the newer syntax Terser itself may use.
More options
Used in the source map and for the downloads (app.js → app.min.js).
The input has changed since this result — minify again to update it.
About the JavaScript Minifier
Paste or open JavaScript and get production-ready minified code from Terser, the minifier webpack uses by default in production mode. It understands current JavaScript syntax — ES modules, classes with private fields and static blocks, import attributes (ES2025), the RegExp v flag and using declarations — and gives you the options that matter: compress (with up to three passes), shorten names, keep class or function names, remove console calls and debugger, keep licence comments, escape non-ASCII characters, choose the output syntax, and write a source map as a separate file or inline.
TypeScript and JSX work too: types are removed and JSX is compiled with Sucrase first, and the source map still points back to your original file. The page shows the size before and after, raw and gzipped — the number that matters on the wire. Everything runs in your browser, in a background thread; your code is never uploaded.
How to use it
- Paste code, drop a file onto the box or press Open file (.js, .mjs, .cjs, .jsx, .ts, .tsx). The input language is chosen from the file extension.
- Check Input and Code type: with “Detect”, code with import or export is minified as an ES module, anything else as a classic script.
- Pick the options — removing console calls, comments, the output syntax and a source map — and press Minify (Ctrl/⌘ + Enter). Changed options apply at once.
- Compare the sizes, then copy the result or download the
.min.jsfile (and the.mapfile, if you asked for one).
Examples
function greet(name) {
const message = "Hello, " + name + "!";
return message;
}
console.log(greet("Asha"));function greet(e){return"Hello, "+e+"!"}console.log(greet("Asha"));The local variable is folded away and the parameter renamed. greet keeps its name because, in a classic script, top-level names are globals other scripts may use.
function save(record) {
console.log("saving", record);
return store.put(record);
}function save(t){return store.put(t)}With console calls: Remove log, info, debug, trace; console.warn and console.error stay.
export const add = (a: number, b: number): number => a + b;
export const add=(d,o)=>d+o;
With Input: TypeScript. Because of the export, it is minified as an ES module.
Common uses
- Minifying a script for a website, a WordPress theme or an HTML email that has no build step.
- Shrinking a snippet before inlining it in a page, a bookmarklet or a tag manager.
- Checking how small a library really gets after minification and gzip.
- Producing a source map so that errors in minified production code point to the original lines.
What minifying changes
Minifying removes whitespace and comments, shortens local variable and function names (mangle) and rewrites code into shorter equivalents (compress: folding constants, removing unreachable code, inlining small functions, joining statements). Properties are never renamed, so objects and APIs keep working.
Two things can change behaviour. Code that relies on Function.prototype.name or class.name — some dependency-injection containers, loggers and frameworks do — needs Keep class names or Keep function names. And removing console calls removes their arguments too: console.log(count++) would no longer increase count.
Scripts and modules
An ES module runs in strict mode and its top-level names are private, so Terser may rename or remove them. In a classic script, top-level variables and functions are globals that other scripts or inline onclick handlers may call, so they are kept unless you tick Also top-level names — do that only when nothing outside the file uses them.
Source maps
A source map (ECMA-426) lets browser developer tools and error trackers show the original file and line for minified code. With Separate .map file the output ends with //# sourceMappingURL=name.min.js.map; upload the map next to the script. Inline embeds the map in the script as a data URL — no extra file, but a much larger download. The map contains your original source code, so do not publish it if the source must stay private.
Older browsers
Terser does not transpile. Output syntax only limits which newer syntax Terser itself may introduce; code that already uses arrow functions, classes or optional chaining keeps them, and the page warns when the ES5 target meets such code. To support old browsers, compile with Babel, SWC or esbuild first.
Limitations
- One file at a time: it does not bundle files or remove unused code across modules. For whole projects use a bundler such as esbuild, Rollup or Vite.
- TypeScript is not type-checked: Sucrase only removes the types. Features that need special compiler output, such as legacy decorators with emitted metadata, are not supported.
- Minified code is not protected: anyone can make it readable again with the JavaScript Formatter. It is not obfuscation.
- Files up to 10 MB. Very large files can take several seconds on phones; a running job can be cancelled and stops after 60 seconds.
Privacy
Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot.
Frequently asked questions
Is minified code safe to use in production?
Yes — Terser keeps the meaning of valid JavaScript, and it is what most build tools use. Still test the minified file, keep class or function names if your code reads them, and ship a source map so errors can be traced back.
How much smaller will my file get?
It depends on the code: comments, whitespace and long local names are what disappear. The sample on this page goes from 766 to 445 bytes (42 % smaller), and from 450 to 328 bytes gzipped (27 %). The gzipped sizes matter most, because servers compress JavaScript before sending it.
Can it minify TypeScript or JSX?
Yes. Choose TypeScript, JSX or TSX as the input (or open a .ts, .tsx or .jsx file): Sucrase removes the types and compiles JSX — to react/jsx-runtime calls or to React.createElement — and Terser then minifies the result.
Why did it say my code is TypeScript?
Statements such as interface User {}, type Id = string or import type { A }, and class members marked private, public, protected or readonly, are TypeScript, not JavaScript. Choose TypeScript as the input so the types are removed first. (Parsed as JavaScript, the current Terser version would hang on some of them and silently change others — static readonly max = 3 would become an instance field — so the page stops before that happens.) Type arguments such as useState<number>(0) are valid JavaScript comparisons, so they are only pointed out in a note.
Should I remove console.log calls?
In production builds that is common: choose “Remove log, info, debug, trace” to keep warnings and errors, or “Remove all”. Note that the arguments disappear with the call, so console.log(i++) no longer increments i.
Is my code uploaded anywhere?
No. Terser and Sucrase run in your browser, in a background thread, and the page works offline once loaded. Nothing you paste or open leaves your device.