What the JavaScript formatter changes
Statements go on their own lines, blocks are indented, and spacing around operators and after keywords is made consistent. The code does exactly the same thing: only whitespace changes. Formatting can't bring back names a minifier shortened, like n and t, or the comments it removed.
When to format JavaScript
- Reading a minified script to see what it does, or to find where an error comes from.
- Tidying code from a snippet, an answer or an AI assistant before you edit it.
- Making two versions comparable before a diff.
JavaScript formatter FAQ
Does it work with modern JavaScript?
Yes: arrow functions, classes, template literals, async/await, optional chaining and modules all format.
Does it check my code for errors?
No. It indents what's there, even if it wouldn't run. The JavaScript Minifier does parse the code, and reports the line and column of a syntax error.
What about TypeScript or JSX?
Most TypeScript formats fine, since it's JavaScript with type annotations. For JSX and large projects, use Prettier in your editor.
Is my code uploaded?
No. Formatting runs in your browser.