JavaScript-Minifier
Schnelle JS-Minifizierung — Kommentare entfernen, Whitespace zusammenfassen, Leerzeilen löschen. Größenvergleich inkl.
Geben Sie oben eine Eingabe ein, um das Ergebnis zu sehen.
What is this for?
A structural JavaScript minifier strips comments and unnecessary whitespace without changing what the code does. The output is functionally identical to the input — same identifiers, same logic — just shorter. This tool runs that pass in your browser, including the tricky bits: it preserves string contents and regex literals untouched, and keeps newlines where ASI (Automatic Semicolon Insertion) would otherwise change behaviour.
When to use it
- Quickly trimming a snippet for inclusion in an HTML bookmarklet or a single-file demo, where you don't have a build chain.
- Sanity-checking how much "fat" is in a hand-written script before deciding whether a real optimiser is worth setting up.
- Inlining a small library into a static site without dragging in a bundler.
Common gotchas
- This is a structural minify, not a compressor. It won't rename variables, dead-code eliminate, mangle properties, or tree-shake. For production builds, use
terser,esbuild, orswcin your pipeline — they cut another 30–60% on top of structural minify. - ASI traps. JavaScript inserts semicolons in surprising places. The minifier preserves a newline where removing it would change meaning (e.g.
return\n{}≠return {}). Stick to explicit semicolons in source if you can — it makes minification safer for everyone. - Source maps aren't generated. If you ship minified JS to production, generate source maps with a real toolchain so debugging is sane.
- Modern compression dominates. Brotli/gzip on the wire does most of what minify does. The biggest wins come from removing unused code — that needs static analysis a structural minifier can't do.
- Don't minify what you commit. Source goes in pretty; minify at build/deploy.