How to use the JSON Formatter
- Paste JSON into the input box (or click Paste to read your clipboard). The output updates as you type.
- Choose Format for readable, indented JSON or Minify for the smallest possible output.
- Optionally change the indentation to 4 spaces or tabs, and switch on Sort keys to order object keys alphabetically at every level.
- If the JSON is invalid, the message under the input tells you the line, column and likely fix; Jump to error puts the cursor there.
- Copy the result or download it as a .json file.
Features
- Live formatting with syntax highlighting for keys, strings, numbers, booleans and null
- Minify to a single line for configs, APIs and query parameters
- Precise error reporting with line, column and hints for trailing commas, single quotes, comments and unquoted keys
- 2-space, 4-space or tab indentation and optional key sorting
- Keyboard shortcuts: Ctrl/Cmd+Enter to format, Ctrl/Cmd+Shift+M to minify
- Handles multi-megabyte documents; highlighting steps aside for very large output to stay fast
What formatting does and doesn't change
Formatting only changes whitespace: indentation, line breaks and spaces after colons and commas. The values, key order (unless you enable sorting) and number representation stay as they were. Minifying removes all optional whitespace, which is what a JSON file looks like when produced by a server; it's byte-identical in meaning.
The formatter is a JavaScript program running in your browser. Nothing you paste is sent anywhere, which matters when the JSON is an API response containing tokens or customer data.
Common JSON mistakes the validator explains
Most invalid JSON is JavaScript that isn't quite JSON. The error messages recognise the usual suspects:
- Trailing commas after the last item in an object or array
- Single-quoted strings or unquoted keys
- Comments (// or /* */), which JSON doesn't allow
- undefined, NaN and Infinity, which have no JSON representation
- Raw line breaks inside strings, and numbers with leading zeros such as 007