About this tool
The JavaScript Minifier reduces the size of a script by removing comments and collapsing unnecessary whitespace and newlines, then reports the byte savings. It is a fast, dependency-free way to shrink a small script or snippet before pasting it somewhere size-sensitive. All processing is local — the code is treated purely as text and never executed, so there is no eval and nothing is uploaded.
This is a conservative, token-aware minifier. It scans the source into tokens, correctly stepping over the interiors of strings, template literals, regular expressions, and comments, so their contents are preserved byte-for-byte. Comments are dropped (or kept, via the toggle), and runs of whitespace are removed everywhere except where a space is genuinely required — between two identifier/number/keyword tokens (so 'return a' never becomes 'returna') or between two operator characters that would otherwise fuse (so 'a + +b' keeps its space). A regex literal following a keyword also keeps its separating space.
Because it does not rebuild an abstract syntax tree, it does not rename variables or perform dead-code elimination — it only removes what is provably safe to remove. It also collapses newlines, so code that relies on automatic semicolon insertion across line breaks should already use explicit semicolons. The panel shows original size, minified size, and the percentage saved.