Developer Tools

Free JS Minifier & Beautifier

Compress JavaScript by removing comments and whitespace, or re-indent it for readability. Safely handles strings, template literals, regex and ASI.

Instant Minify 100% Private Syntax Highlighting Safe Tokenizer

Input JavaScript

0 chars Β· 0 lines Empty
Tip: press Ctrl + Enter to minify instantly. Strings, template literals, regex literals and /*! */ comments are always preserved.

Output

Minified JavaScript will appear here

What Is JavaScript Minification?

JavaScript minification removes every byte that JS doesn't need: comments, unnecessary whitespace, and redundant line breaks. The output runs identically, but downloads faster and parses quicker.

For a typical 100 KB JS bundle, minification alone cuts 15–40% of the size. That's meaningful for page load time β€” especially on mobile networks.

Minify vs Beautify

ModePurposeWhen to use
MinifyRemove whitespace and commentsProduction deployment
BeautifyRe-indent code for readabilityDebugging, code review, learning

What gets removed

What is preserved β€” and why it's hard

Naive minifiers break on three things that a real tokenizer must handle:

The ASI gotcha

JavaScript's Automatic Semicolon Insertion means a newline can act as a semicolon. This breaks naΓ―ve whitespace removal:

function getValue() {
  return
    5;
}

This function returns undefined, not 5 β€” the newline after return inserts a semicolon. A naΓ―ve minifier that collapses the newline produces return 5;, which changes behaviour.

This minifier preserves newlines after the ASI-sensitive keywords return, throw, break, continue and yield. All other newlines are collapsed safely.

What this tool does NOT do

This tool does the safe 80% β€” whitespace and comment removal β€” using a proper tokenizer. That's what you need 90% of the time, and it never introduces bugs.

Common use cases

Production Deploy

Ship the smallest possible JS to every visitor.

Faster Page Load

JS is parser-blocking β€” smaller means faster time-to-interactive.

Debug Minified Code

Beautify minified libraries to understand what a dependency is doing.

Bookmarklets

Compress JS into a single line small enough for a bookmark URL.

Cleaner Diffs

Beautify before committing so Git diffs show real changes.

Email Snippets

Inline minified JS in email templates that have size limits.

Quick Snippet Prep

Minify a snippet before pasting it into a code-golf challenge.

Sanity Check

Run the output through the browser's parser to catch typos.

Privacy and security

This JS minifier runs entirely in your browser. A custom tokenizer walks the source character-by-character, strips unneeded bytes and re-emits the result β€” all in local JavaScript. Your code never leaves your device, safe for internal scripts, proprietary algorithms and unreleased work.

Frequently Asked Questions

What does a JavaScript minifier do?
A JavaScript minifier removes comments and unnecessary whitespace from JS source code. The result behaves identically but is smaller. Typical savings are 15–40% of the original size.
Will minifying break my code?
No. This minifier uses a proper tokenizer that correctly handles strings, template literals, regex literals and ASI (Automatic Semicolon Insertion). It never removes whitespace that would change behaviour.
Does it rename variables?
No. Renaming variables requires a full AST parser and semantic analysis. This tool only removes comments and whitespace, which is safe and doesn't need AST parsing. For maximum compression, use a build tool like Terser or esbuild.
What about the ASI gotcha?
JavaScript's Automatic Semicolon Insertion means return\n5 returns undefined, not 5. This minifier preserves newlines after the ASI-sensitive keywords return, throw, break, continue and yield.
Does it handle JSX, TypeScript, or ESM?
The tokenizer handles plain JavaScript. JSX and TypeScript syntax (like type annotations) may confuse it. ESM (import / export) works, but the optional syntax check will report it as invalid because new Function() only validates function bodies, not modules.
Is my code uploaded to a server?
No. All processing happens locally in your browser using a custom tokenizer. Your code never leaves your device.
Is this JavaScript minifier free?
Yes. It is 100% free, requires no sign-up, and runs entirely in your browser.

Related Developer Tools

Done!