toolo.dev

JavaScript Minifier

Minify JavaScript online with Terser: short local names, dead code removed, strings and regex untouched. Or format minified JS to read it. Shows bytes saved.

After you click or type in the editor, the Tab key indents. Press Escape, then Tab, to move to the next field.

About the JavaScript Minifier

Paste a script into this JavaScript minifier and Terser rewrites it as the shortest code that still does the same thing: comments and whitespace go, local variables get one-letter names, and branches that can never run are dropped. Terser parses your code the way a JavaScript engine does, so strings, template literals, regex literals and URLs containing // come through untouched.

Format mode goes the other way and runs Prettier over minified code, so a production bundle or a third-party snippet becomes readable again. Both libraries load the first time you use them and then run in your browser, so your code isn't sent anywhere.

  1. Paste your code into Input JavaScript, or click Load Example for a short script with comments and three kinds of strings.
  2. Minify is selected from the start. Leave Mangle and Compress ticked for the smallest output, and tick Keep Comments if a license header has to stay.
  3. Choose Single Quotes or Double Quotes. The choice applies to strings in both Minify and Format output.
  4. Read the output in Minified JavaScript. The three boxes above it, Original Size, Minified Size and Savings, update each time you pause typing.
  5. If Terser can't parse the code, JavaScript Error gives the position, for example Line 5, column 1: Unexpected token: punc (}) for a stray brace, and that line number turns red. TypeScript and JSX get an extra hint to compile them first.
  6. Switch to Format to re-indent code in Formatted JavaScript. Copy and Download (minified.js or formatted.js) are in the top corner of the output box.