JavaScript Minifier
Minify JavaScript safely — whitespace and comments removed, identifiers never renamed.
What is JS Minifier?
A conservative JavaScript minifier. It removes comments and the whitespace that carries no meaning, and it never renames a variable, inlines a function or reorders a statement — which is what makes the result debuggable and safe to ship alongside the original.
How it works
The token stream from the same tokenizer the formatter uses is re-emitted with a space only where two tokens would otherwise merge. A newline is preserved where it is significant: after return, throw, break, continue and yield, and before a token that could continue the previous statement such as (, [, +, - or a template literal — the automatic-semicolon-insertion trap.
- Paste the source. Drop in code, a stylesheet, a query or a selector list. Everything is read locally — the page never uploads what you paste.
- Choose the options. Indent width, quote style, keyword case or target browsers. The result updates as you change them, so you can see the effect immediately.
- Copy or download. Copy the result to the clipboard or download it as a file. Reset clears the form and returns every option to its default.
Examples
A 14 KB utility file → 8 KB
Comments and indentation account for most of the reduction; nothing else changes, so a stack trace still points at the same function names.
A file with a return on its own line
`return` followed by a newline keeps that newline, so the function returning undefined on purpose does not silently start returning a value.
Common mistakes
Expecting a formatter to fix invalid code
Formatting is whitespace and quoting. A missing brace, an unclosed tag or an unquoted variable survives the round trip and is reported instead — check the findings list.
Minifying without running the tests afterwards
Even a safe, non-mangling minifier can expose an existing automatic-semicolon-insertion bug. The JavaScript Minifier keeps the newlines that matter, but re-run your tests before shipping.
Treating a rewritten query as verified
The SQL Dialect Converter translates the syntax it can prove; data types, casts and function differences are listed for review, not guessed. Run the converted query against a real database.
Renaming or reformatting generated files
Regenerating a formatter's output is a no-op only if the formatter is the same one that produced it. Keep generated code out of the round trip and format the source it came from.
Frequently asked questions
Why is it only 30–50% smaller than the original?
Because nothing is renamed or eliminated. A bundler-style minifier gets more by mangling identifiers, but the output stops resembling the source — this tool trades some size for output you can still read and trust.
Is it safe on TypeScript?
Only after it has been compiled to JavaScript. Type annotations are syntax this tokenizer does not translate, so minify the build output, not the .ts source.
What about source maps?
A string-level minifier cannot produce a source map that maps back to the original: whitespace is removed without tracking positions. If you need source maps, minify as part of your build instead.