JavaScript Beautifier
Format JavaScript using Prettier — the industry-standard formatter. Browser-only, free.
0 characters
0 characters
About JavaScript Beautifier
The JavaScript beautifier (or formatter) reflows minified or inconsistently formatted JavaScript into a clean, readable form. It uses Prettier, the same opinionated formatter used by millions of projects. The result follows Prettier's house style: 2-space indentation, 80-character line width, semicolons, and double quotes by default.
When to use it
- Reading a minified bundle copied from a network response
- Cleaning up code copied from a Stack Overflow answer
- Normalizing a JavaScript snippet before checking it into source control
- Reformatting hand-edited code to match Prettier's house style
How it works
Prettier parses the JavaScript into an AST using Babel's parser, then re-prints it from scratch according to a fixed set of rules. Original whitespace and most stylistic choices are discarded. Comments are preserved with their attachment to nearby AST nodes.
Examples
Minified → formatted
function double(n){return 2*n}const arr=[1,2,3].map(double);console.log(arr);function double(n) {
return 2 * n;
}
const arr = [1, 2, 3].map(double);
console.log(arr);
Frequently asked questions
- Does it support TypeScript?
- The default parser is JavaScript (Babel). For TypeScript-specific syntax (interfaces, generics, type assertions), the formatter falls back gracefully — most TS code parses fine with Babel-TS. For dedicated TS formatting, use Prettier directly in your project.
- Why does it change my style choices?
- Prettier is opinionated by design — it enforces a single canonical style. Spacing, line breaks, and quote choice are not configurable here. To customize, use Prettier in your project with a .prettierrc file.
- Will it break my code?
- Prettier's parse → reprint cycle preserves all behavior for syntactically valid JavaScript. Some unusual constructs (such as comments inside JSX expression containers) may be repositioned slightly.
- Is my code uploaded anywhere?
- No. Prettier runs in your browser via its standalone build. About 2 MB is lazy-loaded on first use.