Skip to content

JavaScript Minifier

Make JavaScript smaller with Terser, without uploading it.

Everything runs in your browser. Nothing is uploaded.

More Developer Tools

All tools

How to use the JavaScript minifier

Three steps, all in your browser.

  1. 1

    Paste your input

    Type or paste your code or data. Press Sample to try an example.

  2. 2

    Pick the style

    Choose indentation or options. The result updates as you type.

  3. 3

    Copy the result

    Copy the output in one click. Nothing is saved or sent anywhere.

JavaScript Minifier: what to know

The JavaScript minifier uses Terser, the open-source minifier used by default in many build tools including webpack. It parses your code into a syntax tree, then removes whitespace and comments, shortens names of local variables and functions (mangling), and simplifies code, such as folding constants and dropping code that can never run.

Mangling is safe for names that can't be seen from outside their scope. Top-level names in a classic script are global and other scripts may rely on them, so they're left alone. Property names are never renamed, since code elsewhere can access them by string.

The tool shows the original and minified size. Minified code is hard to debug, so for real projects let your bundler minify on each build and generate a source map; this page is best for one-off scripts, bookmarklets, snippets for a CMS or seeing how small a function can get.

Popular uses

  • Minifying a standalone script for a static page
  • Making bookmarklets and snippets compact
  • Checking the minified size of a function
  • Shrinking inline scripts in HTML templates

Tips for the best result

  • Comments that begin with /*! or contain @license or @preserve are usually license notices; check the output keeps any your license requires.
  • If minified code behaves differently, look for code that relies on function.name or on reading its own source.
  • Syntax errors are reported with a line and column so you can fix the source first.

Read how JustYourDev works and our privacy details. Code, data and files you use here are processed in your browser and are never sent to our server.

Frequently asked questions

Terser is the open-source JavaScript minifier used by default in many build tools, including webpack. It parses your code, removes whitespace and comments, renames local variables to short names and simplifies expressions.

No. Names that other scripts may rely on, such as top-level functions and variables in a classic script, are left alone. Only names that can't be seen from outside their scope are shortened.

For a real project, let your bundler minify on every build so the source stays readable. This page is handy for a one-off script, a snippet for a CMS or checking how small a function gets.

No. Every tool runs in your browser, so your code, tokens, keys and files are processed on your device and are not sent to our server or stored. Reloading or closing the page clears them.

Yes. Every tool is free with no sign-up and no limits on use. Clearly labeled ads keep it that way.

Yes. The tools work in any modern browser on phones, tablets and computers, though large files and long code are easier to handle on a computer.