Free JavaScript Minifier

Minify JavaScript code to reduce file size and improve performance. Free, fast, and works entirely in your browser with no sign-up required.

Updated

Share:
Home/Code Tools/JavaScript Minifier

JavaScript Minifier

Minify JavaScript code with multiple optimization levels. Validate syntax, mangle variables, and generate source maps.

Input JavaScript

0 lines
0 B
1

Output

Minified output will appear here

Click "Minify JavaScript" to start

Optimization Levels

Basic

Removes whitespace and comments. Safe for all JavaScript code.

Standard

Adds boolean optimizations (true to !0). Safe for production use.

Aggressive

Enables variable mangling and more optimizations. Test carefully.

Privacy First: All processing happens locally in your browser. Your code is never sent to any server.

Frequently Asked Questions

What is the JavaScript Minifier?

The JavaScript Minifier is a free online tool that compresses JavaScript code by removing whitespace, shortening variable names, and eliminating comments to reduce file size.

Is the JavaScript Minifier free?

Yes, it is completely free with no registration required. All minification happens client-side in your browser.

Will minification break my code?

No, the JavaScript Minifier preserves functionality while reducing file size. The minified code runs identically to the original.

Is my data safe with this tool?

Absolutely. The JavaScript Minifier processes everything client-side in your browser. No data is uploaded to or stored on any server. Your content remains private on your device at all times.

Does the JavaScript Minifier work on mobile devices?

Yes, the JavaScript Minifier is fully responsive and works on smartphones and tablets. You can use it on any device with a modern web browser -- no app download required.

Do I need to create an account to use this tool?

No account or registration is needed. Simply open the JavaScript Minifier in your browser and start using it immediately. There are no sign-up walls or usage restrictions.

How do I use the JavaScript Minifier?

Simply enter your input in the provided field, adjust any settings to your preference, and the tool will process it instantly. You can then copy the result to your clipboard or download it.

Which browsers are supported?

The JavaScript Minifier works in all modern browsers including Chrome, Firefox, Safari, Edge, and Opera. For the best experience, use the latest version of your preferred browser.

What is the difference between minifying and gzipping JavaScript?

Minification and gzip solve the same problem in two stages. Minification rewrites the source itself: it strips comments, whitespace, and newlines, and can shorten variable names so the file holds the same logic in fewer characters. Gzip (or Brotli) is a compression algorithm your server or CDN applies on top of the response as it travels to the browser, where it is automatically decompressed. The two stack: minified code gzips better because it has less redundant formatting for the algorithm to encode. That's why minify first, then let the server gzip. This tool does the first step in your browser and also estimates the gzip transfer size, so you see both the raw minified size and the smaller figure that actually reaches your users. Paste your script above to compare original, minified, and gzip sizes side by side.

What is the difference between the Safe, Production, and Maximum presets?

The three presets trade compression for risk. Safe is the most conservative: it strips comments and collapses whitespace and newlines but leaves your logic completely untouched, so it's the right choice for code you can't fully retest. Production runs the Safe pass and adds deploy-oriented cleanup: removing console and debugger statements and simplifying expressions, producing output ready to ship. Maximum chases the smallest possible file: on top of Production it drops optional semicolons, shortens local variable names, and removes unused variable declarations. The more aggressive the preset, the more the code changes, so retest after using Maximum. Every preset is just a starting point: a panel of individual toggles lets you mix passes by hand, like keeping comments but mangling variables. Pick a preset above, then fine-tune the toggles to match how much you're willing to change.

Why does minified JavaScript shorten variable names?

Variable name shortening, often called mangling, replaces long descriptive names like userAccountBalance with one- or two-character names such as a or b. Those names exist only to help humans read the source; the browser doesn't care what a local variable is called, so renaming it has no effect on how the code runs as long as scope is respected. Shorter names mean fewer characters to download and parse, which adds up across hundreds of references in a real script. The minifier only mangles local variables, leaving globals and anything other code might reference by name intact, so behavior stays the same. Mangling is included in the Maximum preset and available as its own toggle, and the results panel reports how many variables were shortened. Enable variable shortening above when you want the smallest output and can retest the result.

Why should I generate a source map for minified JavaScript?

Minified code is almost impossible to debug directly: variables are renamed, lines are collapsed, and a stack trace points to column 4,000 of a single line. A source map is a separate .map file that records how each piece of the minified output maps back to your original source. When the browser dev tools load it, errors and breakpoints show up against your readable, original code instead of the compressed blob, so you can debug production output as if it were never minified. You reference the map with a comment at the end of the file or an HTTP header, and you typically keep it out of the public download so visitors don't ship it. This tool can generate a source map alongside the minified script as an optional output. Turn on the source map option above before minifying if you plan to debug the result later.

How do I keep license comments when minifying JavaScript?

By default, minification strips every comment, since comments add bytes without affecting how the code runs. That's a problem when a dependency's license requires its attribution banner to stay in the file, because deleting it can breach the license terms. The convention is to mark those comments specially: a block comment that starts with /*! or one that contains an @license or @preserve annotation signals "keep me." This tool has a preserve-license option that keeps exactly those banner comments intact even under the aggressive Maximum preset, while still removing ordinary explanatory comments. So you get the smallest file that's still legally clean to redistribute. Enable the preserve-license toggle above before minifying any code that bundles third-party libraries, then check that the banner still appears at the top of the output.

About the Free JavaScript Minifier

The Free JavaScript Minifier compresses JavaScript source so it downloads and parses faster in the browser. Paste your code, drop in a .js file, or fetch a script by URL, and the tool strips the parts a browser doesn't need at runtime — comments, indentation, line breaks, and other formatting — then reports exactly how many bytes you saved. It is built for front-end developers, plugin and theme authors, and anyone shipping a script who wants a smaller payload without wiring up a full build pipeline.

Minification is the process of removing characters that have no effect on how code executes. Whitespace, newlines, and comments make source readable for humans but add weight that every visitor downloads. On a typical hand-written script, removing them shrinks the file noticeably; combined with shorter variable names and other passes, real-world savings of 30–60% before compression are common.

Choose how aggressively to compress

The minifier ships with three presets so you can match the output to the risk you're willing to take:

  • Safe — strips comments and collapses whitespace and newlines only. The logic is untouched, so this is the lowest-risk option for code you can't fully retest.
  • Production — the Safe pass plus removing console and debugger statements and simplifying expressions, producing deploy-ready output.
  • Maximum — the smallest possible result. It also drops optional semicolons, shortens local variable names, and removes unused variable declarations.

Every preset is just a starting point. A panel of individual toggles lets you mix passes by hand — keep comments but mangle variables, strip console.log without simplifying expressions, and so on. A "preserve license" option keeps /*! ... */ and @license banner comments intact even under aggressive settings, which matters when a dependency's license requires attribution to stay in the file.

See exactly what you saved

Output isn't just a blob of compressed text. The tool shows original versus minified size, the percentage reduction, how many comments were removed, and how many variables were shortened. It also estimates the gzip transfer size — the figure that actually reaches your users, since most servers and CDNs compress responses on the way out. A visual size-comparison bar makes the before/after difference easy to read at a glance, and an optional source map (a .map file that links minified code back to the original) can be generated so you can still debug the compressed output in browser dev tools.

Before minifying, a lightweight validator checks for unbalanced braces, brackets, parentheses, and unterminated strings, comments, or template literals, flagging the line and column. It also warns about eval(), document.write(), and leftover debug statements — issues worth fixing whether or not you minify.

Your code stays in your browser

Pasted and uploaded code is minified entirely on your device using in-browser JavaScript. Nothing you paste or open is uploaded to a server, so proprietary or unreleased code stays private. There's no sign-up, no file-size cap beyond your own memory, and it keeps working offline once the page has loaded. The one exception is the optional "Fetch from URL" field: because browsers block cross-origin requests, that feature routes the address you enter through a public CORS proxy to retrieve the remote script. If a file is sensitive, download it yourself and use the upload or paste option instead.

When to reach for it

A smaller bundle is one of the cheapest wins for page speed: less to download, less to parse, and a faster path to interactivity. Use the minifier for a quick utility script, a WordPress or browser-extension asset, an embedded widget, or a snippet you're pasting into a CMS — anywhere a one-off compression is faster than configuring Terser or esbuild. Copy the result to your clipboard or download it as a .min.js file, ready to ship.