JavaScript Beautifier - Make Minified JavaScript Readable
Paste minified or one-line JavaScript and get it back indented and readable, with syntax errors shown by line and column.
How to Beautify JavaScript - Step by Step Guide
Input Your JavaScript Code
Let's get your JavaScript code into the beautifier! You have several convenient options:
Example: Minified JavaScript Input
Here's what minified, hard-to-read JavaScript looks like:
function calculateTotal(items){let total=0;for(let i=0;i<items.length;i++){total+=items[i].price*items[i].quantity;}return total;}const cart={items:[{name:"Laptop",price:999.99,quantity:1},{name:"Mouse",price:29.99,quantity:2}],discount:0.1};console.log(calculateTotal(cart.items));Automatic Formatting & Beautification
About half a second after you stop typing, the beautifier reads your JavaScript and:
14.50 doesn't turn into 14.5Example: Beautifully Formatted Output
The function from that snippet, as the beautifier lays it out:
function calculateTotal(items) { let total = 0; for (let i = 0; i < items.length; i++) { total += items[i].price * items[i].quantity; } return total; }
Choose Format Options
There are two views of the same code, and you can flip between them:
Export Your Formatted JavaScript
When the code looks right, take it with you:
Frequently Asked Questions
How do I make minified JavaScript readable again?
Paste the minified code (a bundle from a CDN, a script you pulled from a page, a one-line snippet from a bug report) into the input box. About half a second after you stop typing it comes back with one statement per line, nested blocks indented two spaces and spaces around operators. Short variable names like a or e stay short, though: a beautifier only changes layout, so it can't bring back names the minifier threw away.
Will beautifying change what my code does?
It shouldn't. The code is read with Babel's parser first and laid out with Prettier, so only whitespace, line breaks, semicolons, parentheses and trailing commas change. Strings, numbers and regexes are written back exactly as you typed them, so a long ID like 8901240544102066246, a price like 14.50 or a quoted "00501" keeps every character.
What happens if my code has a syntax error?
Nothing gets beautified. Instead you see the line and column where the parser gave up, with that line shown and a caret under the spot, so you can fix it and try again. The beautifier doesn't guess at or repair broken code. If you pasted JSON, CSS or HTML by mistake, it tells you that instead.
What does the Minify button do?
It squeezes the code in the input box back onto as few lines as possible: comments, indentation and line breaks between tokens go, while strings, template literals, regexes and numbers stay untouched. License comments that start with /*! or contain @license or @preserve are kept. Names are never shortened, so for a production build a real minifier like Terser, or our JavaScript Minifier, will get the file much smaller.
Does it handle modern JavaScript and React code?
Yes. Arrow functions, classes, async/await, optional chaining, template literals, BigInt literals, ES modules and JSX in React components all work. TypeScript isn't supported here, because type annotations aren't JavaScript; strip them first or use a TypeScript-aware tool.
Is my code uploaded anywhere?
No. Beautifying and minifying both run in your browser, and the code you paste or upload never leaves your device. That also means the size you can handle depends on your computer: a few thousand lines are quick, very large bundles take a few seconds.
Need a smaller file for production? Try the JavaScript Minifier. Want Prettier formatting with a Clear button and line counts? The JavaScript Formatter does that.