JavaScript Formatter

Minified or bundled JavaScript is optimized for machines, not people. This formatter adds consistent indentation and line breaks around braces, statements, and blocks so you can actually read what a script is doing — useful when inspecting third-party code, debugging a bundled file, or reviewing a snippet pasted from elsewhere.

This formatter indents based on brace/bracket nesting. It does not rename minified variables and may not perfectly handle unusual regex or template literal syntax.

Your data stays in your browser — this tool runs entirely on the client side and nothing is uploaded to a server.

How to Use the JavaScript Formatter

  1. Paste your JavaScript code into the input box.
  2. Click "Format" to re-indent it based on brace and bracket nesting.
  3. Copy the formatted result or download it as a .js file.

Why format JavaScript?

Consistent indentation reveals the structure of a script — which statements belong to which function, loop, or conditional block — without you having to mentally track braces across a dense wall of code. This is invaluable when reading unfamiliar or minified code.

Limitations of automatic formatting

This formatter indents based on brace, bracket, and parenthesis nesting rather than a full JavaScript parser (AST). It handles typical code well, but it does not rename minified variables, does not resolve source maps, and may not perfectly reformat unusual syntax such as certain regular expressions or template literals containing braces. For production codebases, a proper tool integrated into your editor is recommended for daily use.

Example

Minified input
function add(a,b){return a+b;}console.log(add(2,3));
function add(a, b) {
  return a+b;
}
console.log(add(2, 3));

Tips

  • This tool formats code; it does not rename minified variables back to their original names.
  • For daily development, an editor-integrated formatter is faster than a web tool.

Frequently Asked Questions

Will this un-minify variable names?

No. Minified variable names like `a` or `t` cannot be recovered — that information is discarded during minification. This tool only restores whitespace and indentation.

Is my code uploaded to a server?

No, formatting happens entirely in your browser.