Skip to content
SPCXTools

JavaScript Minifier

Compress your JavaScript with Terser — smaller files, same behavior.

Runs locally — files never leave your device

Loading tool…

How to use JavaScript Minifier

  1. 1Paste your JavaScript into the Input box, or click Sample.
  2. 2The minified code appears on the right automatically.
  3. 3Choose whether to shorten variable names and preserve license comments.
  4. 4Copy the result or download it as minified.js.

Make your JavaScript smaller

JavaScript is often the heaviest part of a web page, and every kilobyte has to be downloaded, parsed and executed before the page becomes interactive. Minifying it can cut its size by half or more. This tool uses Terser, the minifier behind most modern build tools, to remove whitespace and comments, shorten names and apply safe code compressions — right in your browser.

Features

  • Terser engine with modern ES2015+ support.
  • Compression: dead-code removal, constant folding and shorter syntax.
  • Name mangling for local variables (optional).
  • License comments kept on request.
  • Size comparison in bytes and percent.
  • Private: code is processed locally.

Typical savings

Code Typical reduction
Well-commented application code 50–70%
Library source 40–60%
Already-compact code 15–30%
Already minified code 0–5%

Serving minified files with gzip or Brotli compression typically reduces the transfer size by another 60–75%.

Tips

  • Keep the original source — minified code is hard to read and debug. Use source maps in your build for debugging production code.
  • Minify as a build step for production; this tool is ideal for one-off scripts, snippets, bookmarklets and projects without a bundler.
  • Test after minifying, especially code that relies on function names or eval.

Related tools

Minify stylesheets with the CSS Minifier, pretty-print data with the JSON Formatter, or encode scripts for embedding with Base64.

Frequently asked questions

What does a JavaScript minifier do?
It removes whitespace and comments, shortens local variable and function names (mangling) and rewrites code into shorter equivalents — for example removing unreachable code and simplifying expressions — without changing what the code does.
Which JavaScript syntax is supported?
Terser supports modern JavaScript (ES2015 and later), including arrow functions, classes, modules, async/await and optional chaining. TypeScript and JSX need to be compiled to JavaScript first.
Is it safe to shorten variable names?
Terser only renames local variables and functions, never global names or object properties, so working code keeps working. If code relies on function names at runtime (for example fn.name), turn off name shortening.
Why do I get a syntax error?
The minifier must parse your code first. Errors usually mean a missing bracket or quote, or syntax that isn't JavaScript — such as TypeScript type annotations or JSX. The message shows what went wrong.
Is my code uploaded?
No. Terser runs in your browser, so proprietary code never leaves your device.