JavaScript Formatter

Format and beautify JavaScript code

About JavaScript Formatter

JavaScript Formatter adds line breaks and indentation around braces, brackets, semicolons, and commas entirely in your browser, and its Minify button does the reverse. Both are string- and regex-aware: they never insert line breaks into or alter the contents of quoted strings, template literals, or /regex/ literals, so a comma or semicolon inside a string stays part of that string's value instead of corrupting it.

How to use JavaScript Formatter

  1. 1Paste your JavaScript into the input box.
  2. 2Click 'Format' to add line breaks and 2-space indentation, or 'Minify' to compress it back down.
  3. 3Review the result in the output box.
  4. 4Click 'Copy' to copy it to your clipboard.

Frequently Asked Questions

Is JavaScript Formatter free to use?

Yes, it's completely free with no signup required.

Does it support minified code?

Yes — Format expands minified code by breaking lines at braces, brackets, semicolons, and commas, while leaving string and regex contents untouched.

Can I customize indentation size or style?

No, formatting always uses 2-space indentation — there's no configuration for tab size, quote style, or line length.

Is my code uploaded to a server?

No, both formatting and minifying happen entirely in your browser.

Tips & Tricks

  • A comma, semicolon, brace, or bracket inside a string or template literal is treated as plain text, not a structural character — it won't trigger a line break or get compressed away.
  • Comments are preserved during Format (kept as-is) and stripped during Minify, matching typical formatter/minifier behavior.
  • This reformats structure only — it doesn't rename variables, reorder code, or fix logic errors.
  • Review the output before using it in production, as with any automated code transformation.