JavaScript Minifier / Beautifier
Input JavaScript
Output JavaScript
About this JavaScript minifier and beautifier
This tool compresses JavaScript by removing comments, extra whitespace, and unnecessary formatting from snippets and small scripts.
It can also beautify compact JavaScript into a more readable structure for review, debugging, and quick edits.
How to use it
- Paste JavaScript into the input field.
- Choose Minify to compress the code or Beautify to format it.
- Copy the generated output and use it in your page, snippet, or build notes.
Tips
- Use minified JavaScript for small inline snippets or quick reductions.
- Use beautified output when reviewing third-party snippets or generated code.
- For production bundles, prefer your project build tool so source maps and modern syntax handling stay intact.
JavaScript minification checks
Do not execute pasted code
This tool treats JavaScript as text, but you should still avoid pasting untrusted code into production projects without review.
Keep source maps elsewhere
Snippet minification does not create source maps. For app bundles, use your build tool so debugging remains possible.
Review modern syntax
Generated or very modern JavaScript may need project-specific transpilation, tree shaking, or environment targeting.
Test after copying
Run your normal tests or browser checks after replacing JavaScript, especially when code contains strings, regexes, or template literals.
JavaScript minification checks before a production release
Minification can alter code when assumptions about syntax, names, side effects, module targets, or runtime support are incorrect.
Target runtime
Set the ECMAScript and browser target explicitly so the output does not contain unsupported syntax or unsafe transformations.
Name preservation
Preserve function or class names when frameworks, reflection, dependency injection, stack traces, or serialization depend on them.
Side effects
Review tree shaking, pure annotations, getters, module initialization, and code whose execution order affects behavior.
Debuggability
Generate protected source maps, upload them to the error service, and run unit, integration, and browser tests against the minified bundle.
Related tools
You may also find these tools useful.