← All Tools
JavaScript Beautifier🔒 100% local
Format and indent JavaScript code for readability. Configurable indent size.
Indent Size (spaces)
JavaScript Input
Related Tools
Runs a character-level reformat over the JavaScript you paste: braces are given their own lines, every semicolon starts a new line, and nesting is indented by the width you set (1 to 8 spaces). There is no parser and no evaluator involved - the text is split on braces, brackets, semicolons and commas and reassembled - so nothing you type is sent anywhere; the whole pass happens in the tab you already have open.
How to use it
- Replace the sample line in the input box with your own JavaScript.
- Set the indent size if two spaces is not what you want.
- Press Beautify and read the result in the lower box, then Copy Output to put it on the clipboard.
Worked example
const x=function(y){return y*2};becomesconst x=function(y){
return y*2
} ;
The space after the opening brace, the semicolon pushed onto its own line and the trailing newline are all part of the tool's output - it does not tidy spacing around operators.
When to use it
- A snippet arrived from a bundle, a log line or a browser console and you want to read the control flow before touching it.
- You are pasting code into a ticket or a blog post and want uniform two-space indentation.
- You need to eyeball one function out of a long single-line file without pulling it into an editor.
What it does not do
- It re-indents characters, it does not parse: missing semicolons are not added, syntax errors are not reported, and long expressions are left on one line.
- Spacing around braces will not match Prettier or ESLint, so do not use the output as your project's formatting standard.
- A brace, bracket or semicolon inside a string or a regex is treated as code because the split is textual, and comment indentation is never adjusted - comments are passed through untouched.