JavaScript Minifier

JavaScript Minifier — Minify JS Online Free

JavaScript Minifier — Minify JS Online Free

Paste your JavaScript below and shrink it in one click. This minifier removes comments and unnecessary whitespace, shows you exactly how many bytes you saved, and runs entirely in your browser — your code is never uploaded anywhere.

What Is a JavaScript Minifier?

A JavaScript minifier is a tool that takes readable JavaScript code and makes the file smaller by removing everything the browser does not need to run it — mainly comments and extra spaces, tabs, and line breaks. The code still does exactly the same thing; it is just harder for a human to read.

Smaller files download faster, so minified JavaScript is a standard step before putting code on a live website. This page does the job for you, free, without installing anything.

What Minifying Removes — and What It Leaves Alone

This minifier is deliberately safe. It only removes things that cannot change what your code does. It never renames variables or functions, because renaming safely needs a full JavaScript parser, and guessing would risk breaking your code.

ThingRemoved?Why
Single-line comments (// ...)YesBrowsers ignore comments completely.
Block comments (/* ... */)YesBrowsers ignore comments completely.
Licence comments (/*! ... */)Only if you uncheck the boxSome licences must stay in the file; the checkbox keeps them.
console.log statementsOnly if you check the boxDebug output is not needed on a live site.
Extra spaces, tabs, and line breaksYesWhitespace between tokens does not change what code does.
Semicolon before a closing brace (;})YesThe semicolon is unnecessary right before }.
Text inside strings, e.g. "https://example.com"NeverChanging string text would change what your code prints or loads.
Regular expressions, e.g. /a\/b/NeverChanging a pattern would change what it matches.
Variable and function namesNeverRenaming without a full parser can break references. This tool does not mangle names.
Spaces that code needs, e.g. in return "hi"NeverSome spaces are required for the code to stay valid, so they are kept.

Worked Example

Here is a real example, minified with this page's own logic using the default settings (the "Remove console.log statements" box checked). The byte counts below were produced by running the minifier on this exact input — nothing is estimated.

Before — 185 bytes:

// Say hello to the visitor
function greet(name) {
  console.log("Hello, " + name);
  return "Hello, " + name; // build the greeting
}

/* Show the greeting on the page */
greet("Ada");

After — 56 bytes (69.7% smaller):

function greet(name){return "Hello, "+name}greet("Ada");

The two comments and the console.log line are gone, the line breaks and indentation are gone, and the semicolon before the closing brace is gone. The greeting still works exactly the same way: calling greet("Ada") still returns "Hello, Ada".

How to Minify JavaScript Online

  1. Paste your code into the input box at the top of this page, or click "Load sample" to try it with an example.
  2. Choose your options. Leave "Remove console.log statements" checked to strip debug output from production code. Check "Keep licence comments" if your file must keep its licence header.
  3. Click "Minify JavaScript". The minified code appears in the output box, together with the original size, the minified size, and the percentage saved.
  4. Check the warning line. If the minifier reports unbalanced braces, brackets, or parentheses, your original code probably has a matching problem — fix it in the original and minify again.
  5. Copy or download. Use "Copy minified code" to paste it into your project, or "Download .js file" to save it as a .js file.
  6. Keep your original file. Minified code is hard to read and debug, so always keep the readable original and only publish the minified copy.

Frequently Asked Questions

Will minified JS still work?

Yes — if your original code is valid, the minified version does exactly the same thing. This tool only removes comments and unnecessary whitespace, and it keeps every space the code needs to stay valid. It never renames variables, so there is no risk of a renamed reference breaking. Always test the minified file once before publishing it, as you would with any build step.

Is my code uploaded anywhere?

No. Everything runs locally in your browser on your own device. Your code never leaves the page, is never sent to a server, and is never stored. You can even disconnect from the internet after the page loads and the minifier will still work.

Does minifying make my website faster?

It makes your JavaScript files smaller, and smaller files download faster, which helps page loading — especially on slow connections. The code itself does not run any faster; minifying only reduces the download size. For the best result, combine minified files with compression (such as gzip) on your web host.

Can I undo minification?

Not with this tool. Minifying is one-way: comments and the original formatting are gone for good. That is why you should always keep your original readable file and only use the minified copy on your live site. If you need readable code back, use a code beautifier — but it cannot restore your deleted comments.

What does the "Remove console.log statements" option do?

When checked, the minifier deletes whole console.log(...) statements from your code, including multi-line ones. Debug messages are useful while you build, but on a live site they add size and can leak internal details into the browser console. Leave it unchecked if your console.log calls are part of the intended behaviour.

Should I minify library files or code I did not write?

Most published libraries already ship a minified version — use that instead of minifying them yourself. If you minify someone else's code, check the "Keep licence comments" box so the licence header stays in the file, as many open-source licences require.

Privacy note: this minifier runs entirely in your browser. Your code is processed locally on your device and is never uploaded to any server, stored, or shared with anyone.

Free online JavaScript minifier by AIToolsForBloggers. Your code never leaves your browser.

Featured on LaunchNest