Skip to content
SmallEasyTools

JavaScript Minifier

Compress JavaScript with the same engine professional build tools use. Shrink your code, optionally shorten variable names and strip console logs, and download a production-ready .min.js file.

  • Free
  • Runs in your browser
  • No sign-up needed

Free and unlimited · runs entirely in your browser

Rate this tool:
Share: Facebook X LinkedIn WhatsApp Email

Quick answer

To minify JavaScript, paste your code into the JavaScript code box or upload a .js file. Choose the options — Shorten variable names (mangle), Remove console.* calls and ES module for code using import/export — and the minified output appears with size statistics. The tool uses Terser, the industry-standard minifier, running in your browser. Syntax errors are reported with the line number.

Engine:
Terser (used by Vite, Webpack and Rollup)
Compression:
Two optimisation passes
Mangle:
Optional variable name shortening
Console removal:
Optional drop of console.* calls
Modules:
ES module mode for import/export
Licence comments:
/*! … */ kept
Errors:
Syntax errors with line numbers
Upload needed:
No – runs in your browser

JavaScript is usually the heaviest part of a modern web page — and unlike images, it has to be downloaded, parsed, compiled and executed before interactive features work. Every kilobyte affects how quickly a page responds, especially on mid-range phones. Code written for humans contains whitespace, comments, long descriptive variable names and debugging statements that the browser does not need.

Our JavaScript minifier uses Terser, the same minifier built into Vite, Webpack, Rollup and many other professional build tools. It does more than remove whitespace: it analyses your code and rewrites it into an equivalent but shorter form — removing dead code, joining declarations, simplifying expressions and conditionals, and running two optimisation passes for better results.

Turn on mangle to rename local variables and function parameters to short names like a and b, which typically saves the most. Turn on Remove console.* calls to strip debugging logs from production code. Enable ES module for code with import and export. Licence comments starting with /*! are preserved.

All of this runs locally in your browser — Terser is loaded into the page, so your source code is never uploaded.

How to minify JavaScript – step by step

  1. 1 Add your codePaste JavaScript or upload a .js file.
  2. 2 Choose optionsEnable mangle for maximum savings, remove console calls for production and ES module for import/export code.
  3. 3 MinifyThe minified code appears with original size, new size and percentage saved.
  4. 4 Fix any errorsIf a syntax error is reported, go to the line shown, fix it in your source and try again.
  5. 5 Test and deployTest the minified file on your page, then download script.min.js and deploy it.

Why use this JavaScript minifier?

Professional engine

Terser, the minifier behind major build tools.

Real compression

Removes dead code and simplifies expressions, not just whitespace.

Variable mangling

Shortens local names for the biggest savings.

Console removal

Strip debug logs from production builds.

Modern JavaScript

Supports ES2015+ syntax and ES modules.

Private and free

Runs in your browser; code never leaves your device.

Minification options explained

OptionWhat it doesWhen to use
Compress (always on)Removes whitespace, comments and dead code; simplifies expressionsAlways
MangleRenames local variables and parameters to short namesProduction code; turn off if other code relies on local names
Remove console.*Deletes console.log, console.warn and similar callsProduction builds
ES moduleParses import/export and enables module-level optimisationsCode written as ES modules

Is mangling safe?

Mangling only renames variables that cannot be seen from outside their scope — local variables, function parameters and, in module mode, top-level names that are not exported. Global variables and object property names are not renamed, so code that other scripts call by name keeps working. Problems are rare but can occur when code relies on function or variable names at runtime, for example reading function.name, using eval or older dependency-injection patterns that read parameter names. If minified code behaves differently, try again with mangle turned off.

How much will I save?

Typical savings with compress and mangle are 30–60% of the original size, depending on how much whitespace, commenting and descriptive naming the code contains. With gzip or Brotli on the server, the transferred size drops further; minification and compression work together. For large applications, the biggest gains often come from shipping less code: remove unused libraries, load features only when needed (code splitting) and avoid bundling large dependencies for small tasks.

Source maps and debugging

Minified code is very hard to debug, because errors point to line 1 of a long single-line file with short names. Build tools generate source maps that let browser developer tools show your original code while running the minified version. This online tool focuses on quick, one-off minification; for applications you maintain, set up a build tool like Vite or esbuild that generates minified files and source maps automatically on each build. Always keep your original source.

Minifying for WordPress, Shopify and other platforms

On WordPress, optimisation plugins minify theme and plugin scripts automatically; use this tool for custom snippets you add via a code plugin or child theme. On Shopify, minify custom JavaScript before adding it to theme assets. For Google Tag Manager custom HTML tags, minified code reduces the container size. Combine with the CSS Minifier and HTML Minifier for a complete front-end optimisation.

Minification, compression and bundling

Three different steps make JavaScript smaller and faster, and they work best together. Bundling combines many source files and their imported libraries into a few files and removes code that is never imported (tree shaking). Minification, which this tool performs, rewrites the code to be as short as possible. Compression with gzip or Brotli happens on the server and shrinks the file further during transfer. A typical 200 KB hand-written script might become 90 KB after minification and around 30 KB after Brotli compression. If you write plain scripts for a small site, minifying here and enabling compression on your host gives most of the benefit without setting up a build system.

Minification is not protection

Minified and mangled code looks unreadable, but it is not secure: anyone can reformat it with a beautifier and, with effort, understand it. Never put secrets — API keys with write access, passwords, private tokens — in front-end JavaScript, minified or not. Keep secrets on the server and expose only what the browser needs.

JavaScript and page speed

Heavy JavaScript increases Interaction to Next Paint (INP) and Total Blocking Time, because the main thread is busy parsing and running code. Beyond minifying, load non-critical scripts with defer or async, remove unused third-party scripts (chat widgets, trackers, old pixels), and lazy-load features that are not needed immediately. Measure before and after with the performance score in the Website Screenshot tool, and verify compression with the HTTP Headers Checker.

Writing code that minifies well

  • Use const and let inside functions and modules, so names can be mangled.
  • Avoid creating many globals; wrap code in modules or functions.
  • Remove debug code with a flag that the minifier can eliminate as dead code.
  • Prefer small, focused libraries or native browser APIs over large utility bundles.
  • Keep licence headers in /*! */ comments so they survive minification.

Privacy

Terser is downloaded into your browser and runs there. The JavaScript you paste — which may contain proprietary logic or client work — is never uploaded or logged.

Troubleshooting

  • "Syntax error on line X". The original code has an error or uses syntax not valid in the chosen mode; fix the line or toggle ES module.
  • "import/export may appear only with module". Turn on ES module.
  • Code works unminified but not minified. Turn off mangle; check for code that depends on function names or eval.
  • Licence comment removed. Start it with /*! so it is preserved.

Frequently asked questions

What does a JavaScript minifier do?

It rewrites JavaScript into a smaller equivalent by removing whitespace and comments, simplifying code and optionally shortening names.

Which engine does this tool use?

Terser, the minifier used by Vite, Webpack and Rollup.

Is it safe to mangle variable names?

Usually yes. Only local names are changed. Turn mangle off if code depends on names at runtime.

Can it remove console.log?

Yes. Enable Remove console.* calls.

Does it support ES6 and modules?

Yes. Modern syntax is supported; enable ES module for import and export.

How much smaller will my JavaScript be?

Typically 30–60% smaller with compression and mangling.

Is my code uploaded?

No. Terser runs in your browser.

Does minifying protect my code?

No. Minified code can be reformatted and read. Never put secrets in front-end code.

Can I upload a .js file?

Yes. Upload a file and download the minified result.

Is the JS minifier free?

Yes. No sign-up required.

Does it keep licence comments?

Yes. Comments starting with /*! are kept.

Does minification change how my code works?

No. Terser produces equivalent code. Test once, especially with mangle on.

Can I minify TypeScript or JSX?

Compile TypeScript or JSX to JavaScript first with your build tool, then minify the JavaScript output.

Should I minify jQuery plugins?

Yes. Most plugins ship a .min.js version already; use that, or minify your own custom plugin code here.

Does it work on mobile?

Yes, though pasting large files is easier on a computer.

Last updated November 21, 2026 · Written and tested by the SmallEasyTools team.