What it does
Beautify reindents your code with consistent spacing: one statement per line inside blocks, one property per line inside object literals, and matching indentation for nested braces, parentheses and brackets. Minify strips comments and non-essential whitespace to shrink the file.
Safe by design
- A real tokenizer reads the code first - strings, template literals (including nested
${...}expressions) and regex literals are always captured whole and never rewritten, so their contents can never be corrupted. - Text inside
`template literals`, including any expression inside${...}, is left exactly as written - it is not reformatted. - If the tokenizer cannot safely read the input (an unterminated string, template or comment, for example), it reports the error with a line and column instead of guessing and producing broken output.
- Minify never removes a semicolon or inserts one, and never rewrites your code's structure - it only strips comments and whitespace. It keeps the one line break most code actually depends on: right after
return,break,continueorthrow, where removing it would silently change what the code does through automatic semicolon insertion.
Good to know
This is a formatter, not a full parser: it lays out code using bracket nesting and a handful of well-known JavaScript rules (regex vs. division, unary vs. binary +/-, ternary : vs. object :), not a complete grammar. It does not rename anything, reorder code or remove dead code. Minify\'s size reduction is modest compared to a build-time minifier like Terser, because it deliberately keeps every line break that could otherwise change behaviour under automatic semicolon insertion - for production builds, use a real bundler/minifier as part of your build process.
Example
This minified code:
const add=(a,b)=>{return a+b};const user={name:"Ada",tags:["a","b"],greet(){return `Hi ${this.name}`}};if(user.tags.length>1){console.log(add(1,2))}else{console.log("none")}is beautified with a 2-space indent into:
const add = (a, b) => {
return a + b
};
const user = {
name: "Ada",
tags: ["a", "b"],
greet() {
return `Hi ${this.name}`
}
};
if (user.tags.length > 1) {
console.log(add(1, 2))
} else {
console.log("none")
}The formatter changes only whitespace and line breaks. It does not add or remove semicolons, quotes or parentheses, the template literal is left alone, and the code means exactly the same as before.
Beautify or minify
Minify goes the other way and removes the whitespace that the code does not need, for example the space after return before a template literal. Variable names are not shortened, so the result is smaller but not obfuscated. For production bundles, use a build tool such as a bundler with a full minifier.
When the code has an error
The tool does not guess. For an unfinished string such as const s = "unterminated; it leaves the output empty and tells you where the problem is: “Could not process this JavaScript at line 1, column 11: This string is not closed before the end of the line.” Fix the code and the formatter works again.
Frequently asked questions
Does it work for TypeScript or JSX?
No. It formats plain JavaScript. Simple TypeScript annotations such as const a: number = 1; pass through unchanged, but angle-bracket syntax is not understood: generics become Array < string > and JSX tags are spaced out as if they were comparisons, without failing. The tool recognises the common signs of TypeScript and JSX and shows a warning under the editor, so the result is not mistaken for a correct one. Check the output, or use a tool built for those languages.
Does formatting change what my code does?
No. Only spacing and line breaks change, so the behaviour is the same.
How do I format JSON instead?
Use the JSON Formatter, which also keeps large numbers exact.
Is my code uploaded?
No. It is formatted in your browser.
Privacy
This tool runs entirely in your browser, including for large files handled by a background Web Worker. What you enter is processed on your device and is not sent to a server.