JavaScript Beautifier turns minified or messy JavaScript into clean, indented code with one statement per line. Paste your code, choose the indent, click the button and copy the result. It is free and runs in your browser.
const numbers=[1,2,3,4,5];let total=0;for(let i=0;i<numbers.length;i++){total+=numbers[i];}if(total%2===0){console.log("The sum of the numbers is even.");}else{console.log("The sum of the numbers is odd.");}const numbers = [1, 2, 3, 4, 5];
let total = 0;
for (let i = 0; i < numbers.length; i++) {
total += numbers[i];
}
if (total % 2 === 0) {
console.log("The sum of the numbers is even.");
} else {
console.log("The sum of the numbers is odd.");
}Bookmark: press Ctrl+D (Windows) or Cmd+D (Mac) to save this tool.
A JavaScript beautifier, also called a JavaScript formatter, adds line breaks, indentation and consistent spacing to JavaScript. Minified code, which is written on one line to save space, becomes easy to read and edit.
The tool changes only whitespace: each statement goes on its own line, code inside braces is indented, and spaces are put around operators and after commas. Variable names, strings, regular expressions, comments and the order of your code stay as you wrote them.
It does not run or check your code. Use it before you edit a minified script, review a pull request or work out what a snippet does.
Each statement goes on its own line, and blocks are indented. These examples use a 2 space indent.
| Before | After |
|---|---|
let x=1;let y=2; | let x = 1; let y = 2; |
function add(a,b){return a+b} | function add(a, b) {
return a + b
} |
const user={name:"Ann",age:30}; | const user = {
name: "Ann",
age: 30
}; |
if(x>0){go()}else{stop()} | if (x > 0) {
go()
} else {
stop()
} |
Reading minified scripts, cleaning up code before you edit it, making code reviews easier and keeping the same style across a project.
The tool does not check your code, wrap long lines, or support JSX and TypeScript. Keep a copy of your original code, or use Undo right after formatting.
To format the markup or styles of a page, use the HTML or CSS beautifiers. To format data, try the JSON or SQL beautifiers.
A JavaScript beautifier takes minified or messy JavaScript and adds line breaks, indentation and consistent spacing, so each statement is easy to read and edit. It is also called a JavaScript formatter.
Paste your code into the box, choose the indent size and click Beautify JavaScript. The formatted code replaces the text in the box. Click Copy to use it, or Undo to go back.
No. The tool only changes whitespace, such as line breaks, indentation and the spaces around operators. It does not rename variables, reorder code, or add or remove semicolons. Strings, template literals, regular expressions and comments are kept as they are.
No. If your code relies on automatic semicolon insertion, the line breaks that matter are kept, so the code still runs the same way. If you want semicolons added, use a linter or your editor.
Beautifying adds spaces and line breaks to make code readable. Minifying removes them, and often shortens names, to make the file smaller. Use a beautifier when you want to read or edit code, and a minifier before you publish it.
You can choose 2 spaces, 4 spaces or a tab. Two spaces is common in JavaScript projects, but use whatever your project or style guide requires.
No. Each statement goes on its own line, and blocks and objects are indented, but a long expression or a chain of method calls stays on one line.
It handles common modern syntax such as arrow functions, classes, async and await, template literals, destructuring, spread and optional chaining. JSX and TypeScript are not supported and may be formatted wrongly.
No. It is a formatter, not a linter or a validator, and it never runs your code. If your code has a syntax error, the tool formats what it can but does not report the error. Use your editor or a linter to find it.
Yes. It is free, needs no account and runs in your browser, so your code is not uploaded to a server.
Last updated: 26 October 2026