JavaScript Minifier — Minify JS Online

Paste JavaScript and get production-ready minified code from Terser — the same engine used by Vite, webpack and Rollup — with real before/after and gzipped sizes.

Runs in your browserUpdated
Open file

Your data never leaves your computer. All processing happens 100% locally in your browser.

How to use the JavaScript Minifier

  1. Paste your JavaScript or open a .js file.
  2. Keep Compress and Mangle names on for the smallest output; tick ES module for code with import/export.
  3. Optionally remove console calls and choose which comments to keep.
  4. Copy the result or download it as .min.js.

What does a JavaScript minifier do?

Minification makes JavaScript smaller without changing what it does. It removes whitespace and comments, shortens local variable and function names, and rewrites code into shorter equivalent forms. Smaller files download and parse faster, which helps page speed and Core Web Vitals — especially on mobile.

This tool runs Terser, the minifier behind Vite, webpack and Rollup, directly in your browser.

The main options

OptionWhat it doesRisk
CompressRemoves unreachable code, folds constants (60 * 60 → 3600), simplifies conditions and joins statementsVery low
Mangle namesRenames local variables and parameters to one or two lettersLow — code that uses eval or Function.name may break
Mangle top-levelAlso renames global functions and variablesBreaks code that other scripts call by name
ES moduleParses import/export and enables strict mode and top-level manglingNone for real modules
Remove console.*Drops console.log and similar callsRemoves logs you may want in production

Minification vs compression

Minification and gzip/Brotli work together. Minifying typically removes 30–60 % of a file; the server’s gzip or Brotli compression then shrinks what is left by another 60–70 %. The stats above show both: the minified size and the gzipped size that will actually travel over the network.

Keep license comments

Open-source licenses such as MIT require the copyright notice to stay with the code. By convention these comments start with /*! or contain @license, and the default setting keeps them.

Troubleshooting

  • Syntax error: the line and column are shown. TypeScript and JSX must be compiled to JavaScript first.
  • Code stops working after mangling: turn off Mangle top-level names; if that does not help, check for eval or code that reads function names.
  • Need a readable version again? Use the JavaScript formatter to beautify minified code.

Tools that pair well with the JavaScript Minifier

  • HTML Minifier — Shrink HTML pages and templates by removing comments and redundant whitespace, minifying inline <style> and <script>, and cleaning up attributes — while keeping the layout identical.
  • JSON Minifier — Remove all unnecessary whitespace from JSON, validate it at the same time and see exactly how many bytes you save — before and after gzip.
  • Website Compression Test — Enter a URL to see which compression your server sends for each Accept-Encoding, how many bytes it saves, whether its CSS and JavaScript are compressed, and what Brotli could save.
  • XML Minifier — Compact XML documents, feeds, sitemaps and SOAP payloads by removing indentation and comments — with a well-formedness check so nothing breaks.

Frequently asked questions

Is Terser better than UglifyJS?
Terser is a maintained fork of UglifyJS that understands modern JavaScript (ES2015+), including classes, arrow functions, async/await and modules. UglifyJS does not support all modern syntax.
Will minified code behave exactly the same?
Yes for normal code. Mangling can break code that relies on eval, with or function names at runtime; turn mangling off for such code.
Can it minify TypeScript or JSX?
No — compile TypeScript or JSX to plain JavaScript first (with tsc, esbuild or Babel), then minify the output.
Is my code uploaded?
No. Terser runs entirely in your browser; your source code never leaves your device.
How do I un-minify JavaScript?
Paste it into the JavaScript formatter. Formatting restores indentation and line breaks, but mangled variable names cannot be recovered without a source map.

Related tools