How to Use the JavaScript Formatter
- Paste your JavaScript code into the input box.
- Click "Format" to re-indent it based on brace and bracket nesting.
- 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
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.