Web Dev & Coding

JavaScript Minifier

The JavaScript Minifier uses Terser, the industry-standard compressor, to safely shrink your code by removing whitespace and comments, mangling variable names, and eliminating dead code — without breaking it.

What is a JavaScript Minifier?

A JavaScript minifier reduces the size of your code by removing whitespace and comments, shortening (mangling) variable and function names, and stripping unreachable dead code — all while preserving exactly how the program behaves. Smaller JavaScript downloads and parses faster, improving load time.

This tool is powered by Terser, the same compressor used by Webpack, Vite, and most modern build tools. Unlike naive find-and-replace minifiers that can corrupt strings, regular expressions, or template literals, Terser fully parses your code into a syntax tree, so the minified output is guaranteed to be functionally equivalent.

How to Minify JavaScript

  • Paste your JavaScript, or click Sample to load an example
  • Minification runs automatically using Terser with compression and name mangling
  • The compact output appears in the right-hand pane
  • If the code has a syntax error, a clear message tells you what went wrong
  • Click Copy to copy the minified code to your clipboard

Why Minify JavaScript?

JavaScript is often the largest asset on a page, and its size directly impacts how quickly a site becomes interactive. Minification can cut file size dramatically — frequently by half or more — by removing everything that exists purely for human readability.

Combined with mangling and dead-code elimination, minification produces the lean bundles that production sites ship. This tool lets you minify a snippet on demand without setting up a full build pipeline.

Safe, Private, and Accurate

Because Terser runs entirely in your browser, your source code is never uploaded anywhere. And because it parses your code properly rather than guessing, you can trust that the minified output behaves identically to the original — strings, regexes, and template literals are all preserved correctly.

Key Features

  • Powered by Terser, the industry-standard JavaScript compressor
  • Removes whitespace and comments, mangles names, and eliminates dead code
  • Parses your code into a syntax tree, guaranteeing functionally identical output
  • Clear error messages when the input has a syntax problem
  • One-click copy of the minified code
  • 100% browser-based — your source code never leaves your device

Why Terser Makes Minification Safe

Not all minifiers are created equal. The naive approach — using find-and-replace or regular expressions to strip spaces and shorten names — is fast but dangerous, because it does not actually understand JavaScript. It can corrupt a string that happens to contain code-like text, break a regular expression literal, or mangle a template literal, producing output that looks minified but behaves differently from the original. For anything beyond trivial snippets, that risk is unacceptable.

Terser, which powers this tool, takes the safe approach: it fully parses your code into an abstract syntax tree, the same structured representation the JavaScript engine itself builds. Every transformation — removing whitespace, shortening variable names, dropping unreachable code — is performed on that tree with full knowledge of the language's rules, then the tree is serialized back to code. Because it understands scope, it knows which names are safe to rename and which must be preserved. This is why Terser is the minifier built into Webpack, Vite, and most modern build tools, and why its output is guaranteed to behave identically to your source.

Why Choose Our JavaScript Minifier?

This minifier is completely free, needs no signup, and runs entirely in your browser. Your source code — which may be proprietary or unreleased — is never uploaded to a server, so you can minify confidently. Because it uses the real Terser compressor rather than a shortcut, you get production-grade results without setting up a build pipeline.

The JavaScript Minifier is one of more than 200 free tools on ToopTools. If you need quick, reliable minification, you can pin it to your personalized My Workspace workspace so it stays beside your other developer utilities, always one click away. It works on any modern browser, on desktop and mobile.

Is the JavaScript minifier free?

Yes. It is completely free with no limits and no signup. You can minify as much JavaScript as you like, as often as you like, without ever creating an account.

Will minifying break my code?

No. Because the tool uses Terser, which parses your code into a syntax tree before transforming it, the minified output is guaranteed to behave identically to the original. Strings, regular expressions, and template literals are all preserved correctly.

What does name mangling do?

Mangling shortens local variable and function names — for example, turning a long descriptive name into a single letter — without changing behaviour, because the tool understands scope and renames every reference consistently. This significantly reduces file size while keeping the code correct.

How much smaller will my JavaScript be?

It varies with the code, but minification frequently cuts size by half or more, especially for code with long names, comments, and generous formatting. Combined with name mangling and dead-code removal, the reduction is often substantial.

Is my source code private?

Completely. Terser runs locally in your browser, so your JavaScript is never uploaded, logged, or stored on a server. It is safe to minify proprietary or unreleased code.

Minification in the Build Pipeline

In a full project, JavaScript minification is normally handled automatically by a bundler such as Webpack, Vite, Rollup, or esbuild as part of the production build. You write readable code with descriptive names and comments, and the bundler runs Terser over the output to produce the compact files that are actually shipped to users. This separation lets you keep developer-friendly source while delivering machine-friendly bundles.

A standalone minifier is still genuinely useful, though. Not every situation involves a build step: you might have a single script for a landing page, a snippet to embed in a CMS, a small widget, or a quick experiment where configuring a bundler would be overkill. In those cases, pasting the code here gives you the same Terser-quality result in seconds. It is also handy for checking how small a particular piece of code compresses, or for producing a minified version on demand without touching your build configuration.

Can I minify ES6+ and modern JavaScript?

Yes. Terser understands modern JavaScript syntax, including arrow functions, classes, template literals, destructuring, and other ES6+ features, so it minifies contemporary code correctly while preserving its behaviour.

How do I minify a JavaScript file?

Paste your JavaScript and the tool instantly removes whitespace, comments, and shortens local names to shrink the file, while preserving exactly what the code does. It shows the size savings and lets you copy the minified output for production.

Does the JavaScript minifier work offline?

Yes. Minification runs entirely in your browser, so once the page has loaded the tool works without an internet connection and your source code is never uploaded — important when the code is proprietary or unreleased.

Related searches

javascript minifierjs minifierminify javascriptcompress javascriptterser onlinejs compressorreduce js size

Recommended Web Dev & Coding tools

Explore more free online tools related to JavaScript Minifier.