JavaScript beautifier

Paste JavaScript to arrange its whitespace, blocks and statements.

JavaScript beautifier

Up to 1 MB of text.

Result

Formatted JavaScript
function greet(name) {
  const message = "Hello, " + name;
  return message;
}

How it is calculated

  1. Strings, comments and regular expressions are kept together.
  2. Blocks and statements are reindented with two spaces.
  3. Formatting runs locally in your browser.

Example

function greet(name){const message="Hello, "+name;return message;}

Good to know

  • The formatter improves layout but does not compile or validate JavaScript.
  • Some complex styles may need manual adjustment.

When to use it

  • Read a minified script to understand what it does.
  • Format code copied from a page or a console before reviewing it.
  • To test a pattern found in that code, use the Regular expression tester.

Frequently asked questions

Can formatting restore the original names?

No. Minifiers often rename variables to single letters; formatting only restores spacing. A source map, when published, can give the original code.

Does formatting change how the code runs?

It should not, as only spaces and line breaks change. Check with care where a line break could change meaning, such as after return.

Is it safe to run code I do not know?

Formatting it is safe, as the code is not executed. Do not run unknown scripts in your browser console.

Updated October 11, 2026

Indicative result. For an important decision, check with a professional.