When to use the JSON Formatter
Reading API responses
Turn a single long line returned by an API into an indented tree you can actually read and debug.
Reviewing config files
Tidy package.json, composer.json or app settings before committing them, so diffs stay small and clear.
Comparing two payloads
Sort keys A–Z on both versions, then compare them side by side or in a diff tool.
Documentation and tickets
Paste neatly formatted examples into README files, Jira tickets or support emails.
Features and benefits
- 2 spaces, 4 spaces or tab indentation
- Optional recursive A–Z key sorting for easy comparison
- Strict validation with line, column and a pointer to the problem
- Private: API responses and tokens never leave your browser
Example
{"id":7,"name":"Desk lamp","tags":["led","usb"]}{
"id": 7,
"name": "Desk lamp",
"tags": [
"led",
"usb"
]
}How the JSON Formatter works
ConvertNest parses your text with a strict JSON parser. If it fails, the error is translated into a line and column with a pointer to the exact character. If it succeeds, the data is printed again with your chosen indentation. Key sorting walks through every nested object and rebuilds it with keys in alphabetical order; arrays keep their order because in JSON the position of array items is meaningful.
A real-life example
A developer’s mobile app suddenly shows blank profile screens. She copies the raw response from the network tab – 4,000 characters on one line – and pastes it here. Formatted with 2-space indentation, it is clear in seconds that the field “avatar_url” has moved inside a new “media” object. Sorting keys on yesterday’s and today’s responses and comparing them confirms that this was the only change, so the fix takes five minutes instead of an afternoon.
Good to know
APIs and log files usually send JSON with no spaces or line breaks to save bandwidth. That is great for machines and terrible for people. Formatting adds indentation and line breaks without changing the data.
Sorting keys is useful when comparing two JSON documents: once both are sorted, a normal text diff shows only the real differences. Array order is never changed, because in JSON the order of array items matters.
Very large integers (above 9,007,199,254,740,991) lose precision in JavaScript. If your JSON contains IDs that large, keep them as strings.
Tips for the best results
- Use 2 spaces for web projects, 4 spaces for Python-style projects, and tabs if your team prefers them.
- Sort keys before comparing two JSON documents; otherwise ordering differences hide real changes.
- Download the result as a .json file to keep the formatted version.
- If the error points at the very end, look for a missing closing } or ].
Common mistakes to avoid
Pasting JavaScript objects
Keys need double quotes and single-quoted strings are not allowed. Replace them before formatting.
Leaving trailing commas
A comma after the last item is invalid JSON. Remove it and format again.
Sorting keys in arrays of ordered data
Sorting only affects object keys, but some APIs depend on key order in practice – keep the original when it matters.
JSON Formatter – frequently asked questions
Is it safe to paste API responses with tokens?
Yes. Formatting runs entirely in your browser. Nothing you paste is sent to a server or stored.
Why does it say my JSON is invalid?
Common causes are trailing commas, single quotes instead of double quotes, unquoted property names and comments – none are allowed in standard JSON. The error shows the line and column to fix.
Does sorting keys change my data?
It changes only the order of keys inside objects, which has no meaning in JSON. Values and array order stay the same.
Can it format JSON with comments (JSONC)?
No. Comments are not part of the JSON standard. Remove them first, or use an editor that supports JSONC.
What is the difference between formatting and validating?
Formatting validates first and then makes the JSON readable. The JSON Validator adds extra checks, such as duplicate keys and a structure summary.
Can I format very large JSON files?
Files of several megabytes work well on a modern computer; extremely large files depend on your device memory.