Beautify JavaScript in Your Browser
This JavaScript formatter turns minified, obfuscated, or inconsistently styled JS into clean, properly indented code you can actually read. Paste a snippet on the left and the beautified result appears on the right the moment you stop typing — no button to press, nothing sent to a server.
When to Use It
Unminify a Bundle
Standardize Style
Review Pasted Code
How to Format JavaScript Code
Add Your Code
Type or paste JavaScript into the Input panel. You can also Upload a .js file (read locally, never sent anywhere) or click Sample to load an example.
Watch It Format
The beautified, syntax-highlighted output appears automatically after a short pause in typing. Press Ctrl + Shift + F to reformat on demand.
Tune the Options
Choose an indent (2, 3, 4, 8 spaces or Tab), set the print width, and toggle semicolons, quotes, and trailing commas. The output re-formats immediately.
Copy or Download
Click Copy to send the result to your clipboard or Download to save a .js file. Use the Edit toggle to tweak the output by hand first.
Formatting Options & Features
JavaScript Style Controls
Prettier is opinionated by design, but these controls let you match your project's style guide. Every change re-formats the output instantly.
| Option | Choices | What It Controls |
|---|---|---|
| Indent | 2 · 3 · 4 · 8 spaces · Tab | Indentation width and character used per nesting level (default 4 spaces). |
| Print Width | 80 · 100 · 120 | Line length Prettier targets before wrapping long statements (default 80). |
| Semicolons | Yes · No | Whether statements end with a semicolon (default Yes). |
| Quotes | Double · Single | Quote style used for string literals (default Double). |
| Trailing Comma | All · ES5 · None | Commas after the last item in multi-line arrays, objects, and parameter lists (default All). |
Built-In Tools
Auto-Format on Input
Output refreshes shortly after you stop typing, with Prism syntax highlighting and line numbers on both panels.
Upload & Download
Load a local .js file or export the formatted result as formatted.js with one click.
Editable Output
Switch the result panel to a CodeMirror edit mode to make manual tweaks before copying or downloading.
Syntax Error Detection
If your code cannot be parsed, the formatter shows a clear error message instead of producing broken output — so you know exactly what to fix. A status bar reports Ready, Formatted, or Error along with the line count and file size.
Frequently Asked Questions
Is my JavaScript code sent to a server?
No. All formatting happens locally in your browser. Uploaded files are read with the browser's FileReader and never leave your device, which makes the tool safe for proprietary and confidential source.
What is the difference between formatting and minifying?
Formatting (beautifying) adds indentation, line breaks, and consistent spacing to make code readable. Minifying does the opposite — it strips whitespace to shrink file size. This tool beautifies; use a minifier when you want to compress code for production.
Does it support modern ES6+ and JSX syntax?
Yes. The Babel parser handles modern JavaScript — arrow functions, async/await, destructuring, template literals, optional chaining, and JSX — so contemporary code is formatted correctly.
Can I customize the indentation and style?
Yes. Pick 2, 3, 4, or 8 spaces (or Tab) for indentation and set the print width, then toggle semicolons, quote style, and trailing commas from the toolbar. The output re-formats as soon as you change any option.
Will formatting change how my code runs?
No. Prettier only rewrites whitespace and cosmetic style — indentation, quotes, semicolons, and line breaks. The behavior of your JavaScript stays exactly the same.
What happens if my code has a syntax error?
Prettier cannot format code it cannot parse, so the tool shows an error message describing the problem instead of guessing. Fix the reported issue and the formatted output appears as soon as the code is valid.
Is there a size limit on the code I can format?
There is no fixed limit. Because formatting runs in your browser, speed depends on your device — large files still format in moments on a modern machine, and the status bar shows the line count and file size.
No comments yet. Be the first to comment!