JavaScript Formatter & Minifier
Paste JavaScript code below to beautify it with consistent indentation, or lightly minify it by stripping comments and blank lines.
How to Use the JavaScript Formatter & Minifier
- Paste your JavaScript code into the input box.
- Click "Beautify" to reindent it based on bracket depth, or "Minify" to strip comments and collapse blank lines.
- Review the result, then click "Copy" to copy it to your clipboard.
- Always keep a backup of your original source file — see the note below on this tool's limitations.
Why Use This Tool?
Is my JavaScript code uploaded anywhere?
No. All processing happens locally in your browser tab using plain JavaScript string parsing. Nothing you paste — including proprietary business logic, API keys accidentally left in code, or unreleased features — is ever sent to a server or stored.
How thorough is the minifier?
This is a lightweight, string-aware minifier built for readability and quick size reduction: it strips // line comments and /* */ block comments (while correctly ignoring anything that looks like a comment inside a string literal), then removes blank lines and leading whitespace. It is not a full production-grade minifier — it does not rename variables, remove dead code, or perform tree-shaking. For a fully optimized production bundle, pair it with a proper build tool like Terser or esbuild.
Is the beautifier a full JavaScript parser?
No — it uses a good-enough bracket-depth heuristic: it splits code on {, } and ; and reindents each resulting line, while staying aware of string literals so braces or semicolons inside quotes don't throw off the indentation. It works well for typical function and object code but is not a substitute for a full AST-based formatter like Prettier on deeply unusual syntax.
Who uses a JavaScript formatter?
Developers pasting minified vendor code to understand what it does, students learning to read JS structure, and anyone needing a quick, no-install way to tidy up a script snippet without setting up a full toolchain.