Developer Tools

JavaScript Formatter & Minifier

Format (beautify) or minify JavaScript — safely, entirely in your browser.

JavaScript Formatter and Minifier Tool

Format or Minify JavaScript

How to Use This Tool

  1. Paste your JavaScript into the input box, or click "Load Sample" to try an example.
  2. Choose Format (to reformat it readably) or Minify (to shrink it).
  3. Click the action button.
  4. Copy the result.

Example

Input:

function hello(){console.log("Hello");}

Formatted:

function hello() {
  console.log("Hello");
}

What "Safe Minification" Means Here

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.

Frequently Asked Questions

What does "Format" do?

It reformats your JavaScript with consistent indentation around braces and semicolons, making blocks and statements easier to read.

What does "Minify" actually remove?

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.

Is this safe for real production code?

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.

Does this handle template literals correctly?

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.

Can this tell a division sign apart from a regex literal?

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.

Is my code sent anywhere?

No. Every transformation runs locally in your browser using JavaScript. Nothing you paste here is sent to Brekzy or stored anywhere.

Find More Useful Tools

Explore Brekzy's growing collection of free calculators, converters, AI tools, and practical resources.