JavaScript Minifier
Minify JavaScript online safely: strip comments and collapse whitespace without renaming or rewriting code. See bytes saved. Free and 100% in-browser.
What is the JavaScript Minifier?
The ByteTools JavaScript Minifier reduces script size by removing comments and collapsing unnecessary whitespace, while leaving your code's logic completely untouched.
- Strips line and block comments safely
- Collapses whitespace outside strings, templates and regex
- Preserves required spaces between identifiers and keywords
- ASI-aware: line breaks kept unless provably safe to drop
- Shows bytes before, after and percent saved
- 100% client-side — code never leaves your browser
How to use the JavaScript Minifier
- 1
Paste your JavaScript into the input box.
- 2
Click Minify JavaScript.
- 3
Review the before/after sizes and percent saved.
- 4
Copy the minified code or download it as a .js file.
About the JavaScript Minifier
The ByteTools JavaScript Minifier reduces script size by removing comments and collapsing unnecessary whitespace, while leaving your code's logic completely untouched. Strings, template literals and regex literals are preserved byte-for-byte, required spaces between identifiers and keywords are kept, and the before/after size with percent saved is shown instantly.
It is intentionally conservative — correctness over compression ratio. Line breaks between statements are preserved unless provably safe to remove, so code that relies on automatic semicolon insertion keeps working exactly as before. There is no variable renaming, dead-code elimination or syntax rewriting, which also means the output stays debuggable.
Everything runs 100% locally in your browser. Your source code is never uploaded to a server, so it is safe for proprietary and commercial scripts.
Frequently asked questions
How is this different from Terser or UglifyJS?
Terser parses your code and aggressively rewrites it — renaming variables, inlining values and dropping dead code — for maximum compression. This tool performs safe, whitespace-and-comment-only minification in your browser. It saves less, but the output is guaranteed to behave identically and remains readable enough to debug.
Can minifying JavaScript break my code?
Aggressive minifiers occasionally can; this one is designed not to. It never touches strings, template literals or regex, keeps mandatory spaces (so 'return x' cannot become 'returnx'), and preserves line breaks wherever automatic semicolon insertion might depend on them.
How much smaller will my JavaScript get?
Comment-heavy, well-indented source typically shrinks by 20–40% with whitespace-and-comment removal alone. Tools that also rename variables achieve more, but for quick wins — especially before gzip compression — safe minification captures most of the practical benefit.
Why are some line breaks kept in the output?
JavaScript's automatic semicolon insertion means a line break can act as a statement terminator. Removing the wrong one merges two statements and changes behavior — for example after 'return'. The minifier only removes a line break when it can prove the join is safe.
Is my code uploaded when I minify it?
No. Minification happens entirely in your browser tab with client-side JavaScript. Your source is never transmitted, logged or stored anywhere.
Guides for JavaScript Minifier
Related tools
JavaScript Formatter
Beautify JavaScript online with token-aware indentation. Respects strings, template literals, regex and comments. A quick, private, in-browser JS formatter.
CSS Minifier
Minify CSS online: remove comments and whitespace, drop trailing semicolons and shorten hex colors. See bytes and percent saved. Free, instant, private.
HTML Minifier
Minify HTML online: strip comments, collapse whitespace between tags and shrink page size. See bytes saved instantly. Free, private, runs in your browser.
JSON Formatter
Format, beautify and minify JSON online with 2-space, 4-space or tab indentation. Sort keys alphabetically and catch syntax errors instantly — free and private.