Free developer tool

JavaScript Minifier

Minify JavaScript with Terser: shorten names, drop dead code and comments, and see the size and gzip savings.
Options

Smaller JavaScript, faster pages

This tool runs Terser, the minifier behind most JavaScript build tools, directly in your browser. It removes whitespace and comments, shortens local variable names, drops unreachable code and folds constants, then shows the size before and after, including the gzip size your server would actually send.

Less JavaScript means less to download, parse and execute, which helps Interaction to Next Paint and Largest Contentful Paint, especially on mid-range phones.

Options

  • Compress: safe code transforms such as removing dead branches.
  • Shorten names: renames local variables and functions. Global names are left alone unless you choose ES module.
  • ES module: allows import and export and lets top-level names be shortened.
  • Keep license comments: preserves /*! and @license comments, which many licenses require.
  • Remove console.*: drops console calls from production code.

Frequently asked questions

Will minifying break my code?
Terser's default transforms are designed to be safe for standard JavaScript. Code that depends on function names (for example, reading Function.name) or uses eval can behave differently, so test the output before shipping it.
Does this support TypeScript or JSX?
No. Terser expects plain JavaScript. Compile TypeScript or JSX first, then minify the result.
Is my code uploaded?
No. Terser is loaded into this page and runs in your browser. Your code never leaves your device.