Category: Developer tools
JavaScript Formatter (Lite)
Re-indent and re-line a small JavaScript snippet
Paste a small JavaScript snippet to re-indent it and break it onto multiple lines around braces, semicolons and commas, without touching the contents of strings, template literals or regular expressions. Runs entirely in your browser.
This is a brace-based re-indenter, not an AST-based formatter like Prettier — always review the output before shipping it.
function greet(name) {
// Say hello to someone
var message="Hello, "+name+"!";
if(message.length>0) {
console.log(message);
}else {
console.log("empty");
}
return message;
}
console.log(greet("world"));Everything on this page is processed in your browser. Nothing is uploaded.
What this tool does
This is a lightweight, brace-based formatter, not a full parser or AST-based tool like Prettier: it tracks strings, template literals, regular expressions and comments closely enough to leave them untouched, then re-indents and breaks lines around `{`, `}`, `;` and top-level `,`. It has no understanding of automatic semicolon insertion or of the language grammar beyond brackets, so it is meant for small, simple snippets, not production source files.
How to use it
- Paste or type a JavaScript snippet into the input box.
- Choose 2-space, 4-space or tab indentation.
- Copy the formatted output, and always review it before shipping it.
Privacy
This tool runs entirely in your browser. Your input is never uploaded, stored or shared — closing the tab removes it.
Frequently asked questions
- Is my code uploaded anywhere?
- No. Formatting runs in JavaScript in your browser tab; nothing is sent to a server.
- Should I use this instead of Prettier?
- No. For production code use a proper AST-based formatter such as Prettier. This tool is meant for quick, small snippets where installing a build tool is not worth it.