Skip to content
Sealpaste

Delete all recent work?

This removes the 0 items saved in this browser. Your settings stay.

Stop saving recent work?

New work won't be saved in this browser. The 0 items already saved can stay or go.

JavaScript Minifier

JavaScript

Paste JavaScript, or

CtrlV paste · Ctrl↵ run now

Minified JavaScript
Ready
Ln 1, Col 1
Runs in your browser. Nothing you paste is uploaded unless you share it.

Minify JavaScript with Terser: names shortened, dead code and comments removed, /*! notices kept, errors by line

Make a script smaller to ship: Terser shortens local names, drops comments and code that can’t run, and keeps license notices.

How to use it

  1. Paste JavaScript, or open a .js or .mjs file.
  2. The status bar shows the characters left and the percent saved.
  3. Copy it or download minified.js. Code with a syntax error is named with its line and column instead.
  4. Under Options: mangling, top-level names, kept names, reserved names, the output ECMAScript version, passes, console calls, comments, quotes, ASCII-only output and an inline source map.

Examples

Local names shortened, the function name kept

Input
function greet(person) {
  const message = "Hello, " + person.name;
  return message;
}
console.log(greet({ name: "Ada" }));
Result
function greet(e){return"Hello, "+e.name}console.log(greet({name:"Ada"}));

greet stays, since other scripts on the page may call it; person and message are only used inside.

A module with its license notice

Input
/*! charts v4 | MIT */
// draw the chart
export function draw(canvas) {
  return canvas.getContext("2d");
}
Result
/*! charts v4 | MIT */
export function draw(t){return t.getContext("2d")}

A call left open

Input
if (debug) {
  console.log("x"
}
Result

Line 3, column 1Unexpected “}”, expected “,”

What Terser changes

Terser, the minifier webpack uses by default, rewrites the code to do the same thing in fewer characters: local variables get one-letter names, a variable used once is put where it is used, unreachable code goes, and so do comments, except /*! and @license ones.

Top-level names stay as they are, so code that other scripts call by name keeps working. import and export statements are kept, so an ES module stays a module.

Going further, under Options

Each choice is Terser’s own. Mangle names is on by default; the others are off until you pick them. Mangle names can be turned off to keep every local name readable; Reserved lists names that are never shortened, such as $ or a name a framework looks up as text. Keep function names leaves function and class names as written, for code that reads .name.

Top-level names also shortens and drops unused names at the top of the file: use it only when the file is a whole program, since another script calling one of those names would break. Output picks the newest syntax Terser may write (ES5, ES2015 or ES2020), and passes runs compress again on its own output for a few more bytes.

Drop console removes console.log() and the other console calls. Comments keeps license comments (/*! and @license), all, or none. Quotes picks single, double, as written, or whichever needs fewer escapes. ASCII only writes other characters as escapes (\xe9, \u2014). Source map adds the map at the end as a data: URL, so the browser’s dev tools show the original lines.

Big files

Up to 10 MB is minified a few statements at a time in a background thread. Each piece is minified on its own, so a big file may come out slightly larger than one run would make it; a single statement over 500 KB is left as written, with a note. Top-level names and the source map need the whole file in one run, so over 500 KB they are left off, with a note.

Questions

Can I minify JSX or TypeScript?
No: Terser reads plain JavaScript, so JSX and type annotations stop with an error at their line. Build them to JavaScript first.
Does it make a source map?
Yes, under Options: Source map adds it at the end of the minified file as a data: URL, so dev tools show your original lines. For a separate .map file, run Terser in your build.
Is my code uploaded?
No. Everything runs in your browser, so your code stays on your device. Nothing you paste is uploaded unless you share a result, which is locked with your password first. Scripts can hold API keys, and the page warns you if it spots one.

Related tools