Format JavaScript with consistent indentation, spacing, and line breaks.
The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.
Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.
Tokens are spaced and indented around braces, brackets, semicolons, and nesting while strings and comments remain opaque. Layout changes do not intentionally change program semantics.
function greet(name){if(name){console.log('Hello '+name);}else{console.log('Hello World');}}
function greet(name) {
if(name) {
console.log('Hello '+name);
}
else {
console.log('Hello World');
}
}
Pre-commit hooks, code reviews, and readable generated bundles format JavaScript.