JavaScript Minifier
Strip comments and unnecessary whitespace from JavaScript. Strings, regular expressions and template literals are preserved, and variable names are not changed.
Use the tool
Why this tool exists
Smaller scripts download and parse faster, and comments and indentation are only for humans. Full minifiers rename variables and rewrite code, which is powerful but needs a build step and can hide bugs.
This tool takes the conservative route. It removes comments and whitespace only, keeping a space or newline where the language needs one so that statements do not run together. Automatic semicolon insertion is respected, so code written without semicolons keeps working. Strings, regex literals and template literals are protected. It suits a small script, a bookmarklet or an inline snippet. For production bundles, use a build tool with tree-shaking and renaming. Nothing is uploaded; the work happens in your browser.
How to use it
- Paste your JavaScript into the input box.
- Read the compact output.
- Copy it into your page, bookmarklet or file.
- Run the result to confirm it behaves as before.
Frequently asked questions
Does it rename variables like Terser does?
No. Names stay as they are, so savings are smaller than with a full minifier, but there is less risk of breaking code and the output remains debuggable.
Is code without semicolons safe?
Yes. The tool keeps line breaks where removing them could change meaning through automatic semicolon insertion, so code written in that style still runs the same.
Are strings and regular expressions protected?
Yes. Strings, regular expression literals and template literals are recognised and copied untouched, so text such as "// not a comment" is not damaged.
Should I use this for production?
For small scripts, yes. For a full application, a build-time minifier with renaming and dead-code removal will produce smaller files.