JavaScript beautifier
Paste JavaScript to arrange its whitespace, blocks and statements.
Result
Formatted JavaScript
function greet(name) {
const message = "Hello, " + name;
return message;
}How it is calculated
- Strings, comments and regular expressions are kept together.
- Blocks and statements are reindented with two spaces.
- Formatting runs locally in your browser.
Example
function greet(name){const message="Hello, "+name;return message;}
Good to know
- The formatter improves layout but does not compile or validate JavaScript.
- Some complex styles may need manual adjustment.
Frequently asked questions
What is this tool used for?
Paste JavaScript to arrange its whitespace, blocks and statements.
How is the result calculated?
Strings, comments and regular expressions are kept together.
What should I check before using the result?
The formatter improves layout but does not compile or validate JavaScript.