TOOLS · JS MINIFIER
Shrink your JavaScript, safely.
Strips comments and indentation without renaming variables or touching line breaks — the two things that make naive JS minifiers actually break code (ASI hazards, regex-vs-division mix-ups). Less aggressive than a full build-tool minifier, but it will never change what your code does.
Why Minify JavaScript?
Minifying JavaScript reduces the amount of code a browser has to download and parse before your page can run, by removing anything that only exists for human readability — comments and indentation. A full production build tool usually goes further, renaming variables to single letters and rewriting logic to be more compact, but that extra aggressiveness is also where most minifier-related bugs come from.
Why This Tool Is Conservative on Purpose
This minifier deliberately only strips comments and indentation — it never renames variables and never joins lines together. That avoids the two classic hazards that break naive JS minifiers: ASI (automatic semicolon insertion) hazards, where removing a line break changes how the parser inserts semicolons, and regex-vs-division ambiguity, where a / can mean either "start of a regex" or "divide," depending on what's around it. The result is less aggressive than a full build-tool minifier, but it will never change what your code actually does.
Common Uses
- Quickly shrinking a standalone script without setting up a bundler or build step.
- Stripping comments and formatting from JavaScript before pasting it somewhere size-constrained.
- Cleaning up code before sharing it, without the risk that comes with heavier minification.
Frequently Asked Questions
Does this rename variables to make the file smaller?
No — variable names are left exactly as written. Renaming variables is where most "minifier broke my code" bugs come from, especially with dynamic property access, so this tool avoids it entirely.
Will this be as small as output from Terser or a bundler's minifier?
No, a full build-tool minifier will produce a smaller file since it renames variables and restructures code more aggressively. This tool trades some of that size reduction for a strict guarantee that behavior never changes.
Is it safe to run on code that uses regular expressions?
Yes — the tool includes a real tokenizer that distinguishes a regex literal from a division operator based on context, rather than guessing with a simple pattern match, which is where a lot of hand-rolled minifiers go wrong.