DevFormatter

JSON Formatter

 

How it works

This tool uses the browser's built-in JSON.parse() to parse your input, then JSON.stringify() to re-serialize it with your chosen indentation. Because it relies on the native JSON parser, it correctly handles all valid JSON including nested objects, arrays, strings with escape sequences, numbers, booleans, and null.

Beautify adds whitespace and line breaks so the structure is easy to read. Minify does the opposite — it removes all unnecessary whitespace to produce the smallest possible output, useful when transmitting JSON over a network. Sort Keys recursively alphabetises all object keys before beautifying. Validate checks whether your input is syntactically correct JSON and reports the exact error with line and column number.

All processing runs entirely in your browser. No data is sent to any server.

JSON Specification

JSON (JavaScript Object Notation) is defined by RFC 8259 (December 2017), which supersedes RFC 7159 and RFC 4627. The canonical grammar is also described at json.org.

Valid value types

  • object — unordered set of key/value pairs: {"key": "value"}
  • array — ordered list of values: [1, 2, 3]
  • string — double-quoted Unicode: "hello"
  • number — integer or floating point, no leading zeros: 42, 3.14, -1e10
  • booleantrue or false
  • nullnull

Common spec violations

  • Trailing commas — {"a":1,} is invalid
  • Single-quoted strings — {'key': 'value'} is invalid; use double quotes
  • Unquoted keys — {key: "value"} is invalid
  • Comments — JSON has no comment syntax; // ... and /* ... */ are invalid
  • NaN / Infinity — not valid JSON number values
  • Leading zeros — 007 is invalid as a number literal

For extended JSON with comments and trailing commas, see JSON5. For schema-based validation, see JSON Schema.

Frequently Asked Questions

What is a JSON formatter?
A JSON formatter takes raw or compact JSON text and adds indentation and line breaks to make it easier to read. It is also called a JSON beautifier or JSON pretty printer.
Is my JSON data sent to a server?
No. All formatting and validation happens entirely in your browser using JavaScript. Your data never leaves your machine.
What is the difference between formatting and minifying JSON?
Formatting adds whitespace and indentation for human readability. Minifying removes all unnecessary whitespace to produce the smallest possible output, which is useful for network transfer.
Why is my JSON invalid?
Common JSON errors include: trailing commas after the last item in an array or object, single quotes instead of double quotes around strings, unquoted keys, and missing or extra braces/brackets.

Related Tools

Other free developer tools available on DevFormatter.