Format (beautify) or minify JavaScript — safely, entirely in your browser.
Input:
Formatted:
This tool prioritizes correctness over maximum compression: it removes comments and unnecessary whitespace, but never renames variables or restructures your code, and never touches the contents of a string, template literal, or regex literal. It is not a substitute for a real build-tool minifier on a production project, but it's safe for quick, everyday use.
It reformats your JavaScript with consistent indentation around braces and semicolons, making blocks and statements easier to read.
Comments and unnecessary whitespace (extra blank lines). It deliberately does NOT rename variables, join separate statements onto one line, or otherwise restructure your code -- that keeps the transformation safe and predictable, though it won't shrink the file as much as a full production minifier like Terser would.
For the vast majority of everyday JavaScript, yes -- strings, template literals, and comments are protected before anything is stripped, so their contents are never touched. Regular expression literals are detected using the same heuristic real minifiers use (checking whether the previous token allows a value position), not a full parser, which very rarely can misjudge unusual code. Always review the result before deploying it, and keep your original source as the version you actually edit.
Yes -- a template literal (backtick-delimited string) is tokenized as a single protected unit, so any braces, colons, or semicolons inside it (including inside a ${...} expression) are never touched by the formatter or minifier.
Yes, using the standard heuristic: a `/` is treated as starting a regex literal only when the previous meaningful token is something a regex can legally follow (like `(`, `,`, `return`, or the start of the file) rather than a value (like a variable name or a closing `)`). This is not a full parser, so it's not infallible on unusual code, but it correctly handles the vast majority of real-world JavaScript.
No. Every transformation runs locally in your browser using JavaScript. Nothing you paste here is sent to Brekzy or stored anywhere.
Explore Brekzy's growing collection of free calculators, converters, AI tools, and practical resources.