Messy input
function add(a,b){if(a==null)a=0;return a+b}const xs=[1,2,3].map(n=>n*2);The JavaScript Formatter reformats cluttered or minified JavaScript into clean, consistently indented code. It adds proper line breaks, normalizes spacing around operators and braces, and applies a uniform statement layout so the structure of functions, loops, and conditionals becomes obvious. All processing happens in your browser, meaning your source code, including any keys or business logic, is never transmitted to a server.
JavaScript is the programming language of the web, running in every browser and, via Node.js, on servers and tooling. Production bundles are minified to reduce download size, which strips whitespace and renames variables. Reformatting restores readability so you can study third-party scripts, debug a stack trace, or tidy hand-written code. Consistent formatting also reduces diff noise and helps a team maintain a single shared style.
The main file is the entry point for each run.
Use the Input panel to pipe standard input to your program when it needs data.
Run sends your code to a fresh hosted runtime and streams the result into the output panel.
Your draft stays in this browser, and Share creates a separate snapshot link.
function add(a,b){if(a==null)a=0;return a+b}const xs=[1,2,3].map(n=>n*2);function add(a, b) {
if (a == null) a = 0;
return a + b;
}
const xs = [1, 2, 3].map((n) => n * 2);async function getUser(id) {
const res = await fetch(`/api/users/${id}`);
const data = await res.json();
return data;
}class Counter{constructor(start){this.count=start||0}increment(){this.count++;return this.count}}class Counter {
constructor(start) {
this.count = start || 0;
}
increment() {
this.count++;
return this.count;
}
}fetch('/api/data')
.then((res) => res.json())
.then((data) => {
console.log(data);
})
.catch((err) => {
console.error(err);
});function label(status) {
switch (status) {
case 'open':
return 'Open';
case 'closed':
return 'Closed';
default:
return 'Unknown';
}
}const{name,age=18,...rest}=user;const[first,,third]=items;const { name, age = 18, ...rest } = user;
const [first, , third] = items;try {
const data = JSON.parse(input);
return data.value;
} catch (err) {
console.error('Invalid input', err);
return null;
}The editor uses Monaco, the engine behind VS Code, with language-aware editing tools and familiar keyboard controls.
Paste cluttered or minified JavaScript and get cleanly indented code back.
Functions, loops and conditionals are laid out so their structure is clear.
Line breaks and spacing around operators and braces are normalized.
Applies a uniform statement layout across the whole script.
Helpful for reading third-party scripts or unminifying a bundle.
Makes debugging a stack trace far easier by restoring readability.
All processing happens in your browser, so source code is never transmitted.
Any keys or business logic in the code stay on your machine.
Copy the formatted output to drop back into your editor.
Reduces diff noise so reviews focus on real logic changes.
Output
Start typing to auto-process