JavaScript Formatter & Beautifier Online
- This tool runs entirely in your browser. Nothing you enter or upload is sent to a server.
JavaScript
Formatted JavaScript
Result appears here.About this tool
Paste minified or untidy JavaScript and get consistently indented, readable code. It uses Prettier, the same formatter many teams run in their editors, so the output follows widely accepted style.
Modern syntax is supported: ES modules, async/await, classes, template literals, optional chaining and JSX. If the code has a syntax error you see the first line of the message instead of broken output.
To use it, paste your code or press Sample, choose 2 spaces, 4 spaces or tabs, then copy the result or download it as script.js. A line like function greet(name){if(!name){return 'Hi'}return Hi ${name}} is expanded so the function body, the if block and each return sit on their own indented lines, with semicolons added and quotes normalised to Prettier’s defaults.
Be aware that Prettier is opinionated. It rewrites quotes, adds semicolons, wraps lines at 100 columns and adds or removes parentheses, but it never renames variables or reorders statements. Comments are kept. Because it must parse the code first, a stray bracket or an unsupported syntax such as TypeScript types stops the formatting entirely.
Formatting runs locally in your browser, so unreleased code never leaves your machine.
Frequently asked questions
Does it change what my code does?
No. Formatting only changes whitespace, line breaks, quotes and parentheses in ways that do not alter behaviour.
Can it format TypeScript?
Not on this page — it handles JavaScript and JSX. For JSON, HTML and CSS use the matching formatters.
Can it un-minify code?
It restores structure and indentation, but minified code also loses its original variable names, which cannot be recovered.
Does it also minify or obfuscate?
No. This tool only beautifies. It will make code longer and more readable, never smaller.
Why does it add semicolons and change my quotes?
Those are Prettier’s defaults: semicolons at the end of statements and double quotes for strings, switching only when that avoids escaping. The output is consistent, even if it is not your team’s style.
Does it support JSON or Node scripts?
Plain Node scripts format fine, since they are ordinary JavaScript, including require calls and ES module imports. For JSON, the JSON formatter is the better fit because it also validates and can sort keys.