Skip to content
GivenTool

Format and beautify JavaScript

Beautify minified or messy JavaScript and JSON-like code with your choice of indentation and brace style.

0 / 1,000,000 characters · Updates as you type.

Settings
Runs in your browser. Nothing you type is sent anywhere.

Minified JavaScript is a single line with every space removed, and code pasted from a chat, a PDF or an old project is often indented in several different styles at once. Either way, reading it is slow. This formatter lays the code out consistently: one statement per line, blocks indented by the width you choose, spaces around operators and after commas, and long chains broken where it helps.

You can pick two spaces, four spaces or tabs, and the brace style your team uses: braces on the same line as the if or function, braces on their own line (Allman style), or the variant that puts else on a new line. Blank lines from the input can be kept (up to two in a row) so the original grouping survives, and long lines can be wrapped at 80 to 120 characters. Modern syntax such as arrow functions, classes, template literals, async/await, optional chaining and spread is handled.

Formatting is done by js-beautify (MIT), about 17 KB compressed and loaded only when you format something here. It is a beautifier, not a compiler: it does not check that your code runs, it cannot rename minified variables back to their original names, and it does not reorder anything. For source that was bundled, a source map from the original build is the only way to recover real names. The code never leaves your browser.

How to use it

  1. Paste the JavaScript (minified or not) into the input.
  2. Choose the indentation and brace style.
  3. Read the formatted code as you type; turn blank-line preservation off for very compact output.
  4. Copy the result or download formatted.js.

Frequently asked questions

Can it restore original variable names from minified code?

No. Minifiers replace names like totalPrice with a or b, and that information is gone. Only the source map from the original build can map them back.

Does it support TypeScript or JSX?

Simple TypeScript and JSX usually format acceptably, but type annotations and JSX are not fully understood. Use your editor's formatter (for example Prettier) for those projects.

Will formatting break my code?

It only changes whitespace and line breaks, which JavaScript ignores in almost every case. Automatic semicolon insertion can matter in unusual code without semicolons, so run your tests if you format production code.

Does it check for errors?

No. It formats what you paste, even if it would not run. Use your browser console or a linter to find syntax errors.

Can I format JSON with it?

Yes, but the JSON formatter is better for JSON: it validates the input and reports the exact position of errors.