JavaScript Formatter

Beautify minified JavaScript code

How to format JavaScript

  1. Paste minified or badly formatted JavaScript or JSON-like code.
  2. Choose 2 spaces, 4 spaces or tabs and press Format.
  3. Statements are placed on separate lines, blocks are indented, and spacing around operators, commas and braces is made consistent.
  4. Copy the formatted code or download it as a .js file.

Reading minified code

Websites ship minified JavaScript to load faster, but when you are debugging a production error, auditing a third-party tag, checking what a browser extension does or learning from someone else's code, a single line of thousands of characters is unreadable. Beautifying puts the structure back so you can follow the logic, search for API calls and set breakpoints in the right place.

Formatting cannot undo every part of minification: comments are gone and local variables renamed to single letters stay that way. If the site publishes source maps, your browser's DevTools can show the original files. Code that has been deliberately obfuscated will become more readable but may still be hard to follow.

This page uses js-beautify, a mature formatter used by many editors. The library is downloaded once and your code is formatted locally; it is never uploaded.

FAQ

Is this the same as Prettier?

Both format code. Prettier is more opinionated and rewrites layout fully; js-beautify keeps more of your existing structure and blank lines.

Can it format TypeScript or JSX?

Simple TypeScript and JSX usually format acceptably, but for full support use Prettier in your editor.

Does formatting change behaviour?

No. Only whitespace and line breaks change, so the code runs exactly the same.

Made by BufferMint. We also design and build software products for founders. See our services →

Your files and inputs never leave your device; we only count anonymous visits.