JavaScript Minifier
JavaScript is where the weight of a modern page really sits. It is not only the bytes a visitor downloads, but the script the browser then has to parse and run before the page becomes interactive. Source code is written for people, with descriptive names, spacing, comments, and the occasional branch that never runs, and almost none of that needs to ship. This minifier runs Terser, the same engine bundlers reach for, right in your browser. You paste a script and get back a compressed version with short local names and dead code removed, and the original, minified, and gzip sizes sit together so the saving is never a guess. It reads the JavaScript properly, so the output is a safe, equivalent program, and nothing you paste leaves the tab.
- Runs Terser, the same minifier bundlers use for production builds, so it reads your code into a syntax tree and transforms it safely rather than guessing
- Removes real weight, not just spaces, by dropping dead code, folding constants, and shortening local names, which is where the gzip-resistant saving comes from
- Shows the original, minified, and gzip sizes together, so you judge the result by what a server actually sends rather than the raw byte count
- Runs entirely in your browser, so the code you paste, including proprietary work, stays on your device and is gone when you close the tab
Overview
Minifying JavaScript is more involved than CSS, because you are rewriting a program rather than trimming text, so accuracy matters most. This tool leans on Terser to do it properly, and shows the numbers that prove it was worth doing.
- 01
Terser under the hood
The same minifier the major bundlers use for production builds. It reads your code into a tree and transforms it safely, rather than guessing with text patterns.
- 02
Compression that removes real weight
Dead code and branches that never run are dropped, constants are folded, expressions are simplified, and redundant statements collapse. These are the structural wins that removing whitespace alone can never reach.
- 03
Short local names
Local variables and parameters are renamed to one or two characters, while top-level globals and reserved words stay untouched, so the program keeps working and the bytes keep shrinking.
- 04
License comments kept
The license and preserve banners that open-source code requires can stay, while every other comment is removed from the output.
- 05
A size breakdown you can trust
Original, minified, and gzip sizes update as you type, with the exact percentage saved. The gzip figure is the one that reflects what crosses the network.
- 06
Copy, download, or upload
Paste from the clipboard, load a file from disk, then copy the result or save it as a min.js file. The whole loop happens locally in seconds.
How to use
Turn readable source into a production-ready, minimal script in a few steps, with the saving on screen throughout.
- 01
Paste your JavaScript into the input panel, or use Upload to load a file directly.
- 02
Pick your options. Keep Compress and Mangle on for the smallest output, and keep license comments if you ship a banner.
- 03
Watch the breakdown below the options to confirm the gain, with the original, minified, and gzip sizes and the percentage saved.
- 04
If the input has a syntax error, the message is shown so you can fix it. Otherwise copy the result or download it as a min.js file.
- 05
Wire the minified file into the page or build step that serves your production scripts.
Details
The details that make the output safe to ship and quick to trust.
- Built on Terser, the standard JavaScript minifier used across the major bundlers.
- Modern syntax is supported, including arrow functions, classes, async and await, template literals, and optional chaining.
- The gzip size is measured with the compression built into your browser, so the figure matches what a real server would transfer.
- A syntax error is reported in place with its message, instead of quietly producing broken output.
- Nothing is uploaded or logged. The code you paste, including proprietary work, stays in your browser and is gone when you close the tab.
Use cases
Where compressing JavaScript to its essentials pays off.
-
Faster, more interactive pages
A smaller script downloads, parses, and runs sooner, which improves Time to Interactive and the Core Web Vitals that affect both users and search ranking.
-
A build step without a bundler
On a static site, a widget, or a snippet you embed elsewhere, paste the script here for the same minification a pipeline would apply, with no toolchain to set up.
-
Shipping an embeddable script
When others will drop your script onto their pages, a single minimal file is what you want to hand them, so minify before you publish the distributable.
-
Trimming generated code
Vendor libraries and generated bundles sometimes arrive unminified. Run them through here to recover the bytes before they reach your users.
See also
Shipping styles alongside your scripts? Pair this with theCSS Minifier , and when you would rather expand and tidy code than shrink it, theSQL Formatter formats the other direction.
What a JavaScript minifier really does
Minifying JavaScript goes well beyond deleting spaces. Because it rewrites the program itself, it helps to know the moving parts, what each step does, and why the result still runs the same.
-
Whitespace and punctuation
Indentation, line breaks, and unneeded semicolons are removed, and the parser rules let many be dropped entirely. This is the cheapest, safest layer, and the one gzip would mostly recover on its own.
-
Compression, the structural pass
Terser evaluates constant expressions, removes code that can never run, inlines simple values, and collapses statements. This is where the real saving comes from, the kind gzip cannot reach, because it removes content rather than formatting.
-
Renaming local names
A long, descriptive local name becomes a single letter. Only names that are safe to change are touched. Globals, object properties, and anything exported are left alone, so the program behaves the same.
-
What stays untouched
Public names, object property keys, string contents, and reserved words are kept by default. That is why minified code still talks to other scripts and the page correctly, because the visible contract does not change.
-
Why gzip is the honest number
Servers compress JavaScript with gzip or brotli, and those already squeeze repeated whitespace and tokens. Minifying still wins by removing whole branches and shortening names, but you should always judge the result by the gzip size rather than the raw bytes.
-
Minify, do not obfuscate
Minification aims for the smallest equivalent program and keeps it debuggable with a source map. Obfuscation deliberately makes code hard to read, and often larger and slower. They have different goals, and this tool does the first.
Best practices
Habits that keep minified JavaScript both small and reliable.
- Minify as the final build step and deploy the output. Never hand-edit minified code or commit it as your source of truth.
- Judge the saving by the gzip size, since that is what the server transfers. A big raw reduction often shrinks once compression is applied.
- Generate a source map alongside the minified file, so production stack traces and the debugger still point back to your real code.
- Keep Compress and Mangle on for production, but if a runtime relies on a function name, as some frameworks do, protect that name rather than turning off renaming for everything.
- Serve the minified file with gzip or brotli and a long cache lifetime. Minification and transport compression stack rather than replace each other.
Limitations
What this tool does, and what it leaves to other steps.
- It minifies a single JavaScript file. It does not bundle modules, resolve imports, or follow references to other files.
- It minifies but does not transpile. Down-levelling modern syntax for old browsers is a separate job for a tool like Babel or esbuild.
- Source written in TypeScript or with JSX must be compiled to plain JavaScript first, since only standard JavaScript is read here.
- Source-map generation and obfuscation are out of scope. This tool focuses on producing the smallest equivalent program that is still debuggable.
FAQ
Common questions about minifying JavaScript, what it changes, and when to use it.
Will minifying break my JavaScript?
No, as long as the input is valid. Terser reads your code into a tree and only applies changes that keep behaviour the same. It renames local variables, removes dead code, and shortens expressions without changing what the program does. Public names, properties, and exported identifiers are left alone. The one thing to watch is code that relies on a function or variable name at runtime, as some dependency setups do. In that case, protect those names or turn off renaming.
What is the difference between compress and mangle?
Compress is the structural pass. It removes dead code, folds constants, and simplifies expressions, which is where most of the saving that gzip cannot reach comes from. Mangle is the renaming pass. It shortens local variable and parameter names to one or two characters. They are independent, so you can run either or both, and together they produce the smallest output.
What is the difference between minifying and obfuscating?
Minifying makes code as small as possible while keeping it equivalent and, with a source map, debuggable. Obfuscation deliberately makes code hard to understand, often at the cost of size and speed. They share some techniques but have opposite goals, and this tool minifies rather than obfuscates.
Does it support modern JavaScript?
Yes. Terser understands current syntax, including arrow functions, classes, async and await, generators, template literals, optional chaining, and nullish coalescing. It minifies modern syntax but does not down-level it for old browsers, which is a transpiler job.
Can I minify TypeScript here?
Not directly, since this tool works on plain JavaScript. Compile your TypeScript or JSX to JavaScript first, which your build already does, then paste or upload that output here to minify it.
Should I keep the minified file in my repository?
No. Minified JavaScript is a build artifact, not source. Commit the readable code you actually edit, and generate the minified file as the last step before serving. Checking in minified output makes reviews hard to read and merges painful.
Is my code uploaded anywhere?
No. Everything runs in your browser. The JavaScript you paste, any file you upload, and the result are processed locally, never transmitted or stored, and disappear the moment you close the tab, so even proprietary code is safe.
Related tools
Keep going with the rest of the data and format toolkit.