Developer Tools

JavaScript Minifier

Minify JavaScript code online for free — strip comments and collapse whitespace while leaving strings and template literals untouched, instantly inside your browser.

Private by default Instant results No signup
JavaScript MinifierLive
JavaScript source
Minified output
0Original size (chars)
0Minified size (chars)
0%Size reduction
Overview

What is JavaScript minification?

JavaScript minification removes what a script doesn't need to run correctly — comments and extra whitespace — to shrink its file size without changing what the code actually does. Full-scale minifiers also rename variables and restructure expressions using a complete parser; this tool takes a lighter, safer approach, focused on stripping comments and collapsing whitespace while carefully leaving the contents of every string and template literal completely untouched.

That makes it a good fit for quickly shrinking a script before pasting it somewhere space-constrained, without the risk of a full parser subtly rewriting logic it misunderstood.

Guide

How to use it

1Paste or upload your JavaScript
2Toggle the cleanup rules you want applied
3Check the size reduction in the stat row
4Copy or download the minified result

How each option works

"Remove comments" strips every // and /* */ comment from the code. String and template literals are scanned and copied through untouched first, so a comment marker or quote character that happens to appear inside a string is never mistaken for real code. "Collapse whitespace" reduces repeated spaces and blank lines down to a minimum. "Strip line breaks" goes further and joins everything onto fewer lines — safe for code that uses semicolons consistently, but risky for code that relies on automatic semicolon insertion, since removing a line break can change where a statement is understood to end.

Why it helps

Features & benefits

String and template literal contents are never altered
Independent toggles for comments, whitespace, and line breaks
Live before/after size and percentage saved
Upload a .js file or download the minified result
100% private — nothing leaves the device

Why this runs entirely in your browser

Scripts pasted here can include unreleased features or internal logic, so nothing is uploaded. Every cleanup rule runs in JavaScript locally in the tab, which means it keeps working offline once the page has loaded and nothing pasted into it persists after the tab is closed.

A note on what this doesn't do

This tool doesn't rename variables, shorten function bodies, or restructure expressions the way a full build-time minifier (like Terser or esbuild) does — those tools parse code into a full syntax tree and can safely make much deeper changes. For a quick, low-risk size reduction on a script you're pasting somewhere directly, this lighter approach is a solid fit; for production bundling, a proper build-time minifier will get you a meaningfully smaller result.

Frequently asked questions

A few things people usually want to know before trusting the numbers.

Only if your code uses semicolons consistently. JavaScript can infer missing semicolons based on line breaks, so removing them can occasionally change how a statement is parsed — leave this option off if you're not sure.

No. Strings and template literals are detected and copied through exactly as written, so quote characters, comment-like text, and formatting inside them are never modified.

No — it intentionally avoids that. It only removes comments and collapses whitespace, which is a safer, lower-risk form of size reduction than a full parser-based minifier.

Yes. Use the upload icon above the input box to load a .js file directly.

No. All minification happens locally in your browser. Nothing typed or uploaded here is sent to a server, stored, or shared.