Code / Code formatting

JavaScript Formatter

Format JavaScript and JSON using a modern parser.

Workspace

Browser-based

How to use JavaScript Formatter

Format JavaScript with Prettier, a syntax-aware formatter that produces consistent indentation and line breaks.

  1. Paste JavaScript into the source editor.
  2. Select Format code.
  3. Review and copy the formatted output.

Example

Input

const a={x:1,y:2}

Result

const a = { x: 1, y: 2 };

Important to know

Formatting changes presentation, not program intent. Invalid JavaScript produces a parser error.