Guides › Text, code, and data
JSON formatting explained: validate, pretty-print, and minify
Last updated 10 October 2026 · Written by Souren Das
JSON is the format most web APIs, config files, and apps use to pass data around. When it arrives as one long line, it is unreadable. When one comma is out of place, the whole thing fails to load, often with an error that only says "Unexpected token". This guide explains what valid JSON looks like, the mistakes that break it, and how to validate, pretty-print, and minify JSON in your browser with Dev Tools.
What JSON is
JSON (JavaScript Object Notation) is plain text that describes data using a few building blocks:
- Objects in curly braces, holding "name": value pairs separated by commas: {"city": "Bengaluru", "pin": 560001}
- Arrays in square brackets, holding values separated by commas: ["pdf", "png", "jpg"]
- Strings in double quotes: "hello"
- Numbers without quotes: 42, 3.14, -7
- true, false, and null, written in lower case without quotes.
Objects and arrays can be nested inside each other to any depth. That is the whole language. It is defined in a short standard (RFC 8259), which is why nearly every programming language can read it.
Pretty-printed versus minified
The same data can be written two ways. Pretty-printed JSON puts each value on its own line with indentation, so a person can read it:
{
"name": "FileTools Kit",
"tools": [
"merge-pdf",
"text-diff"
]
}
Minified JSON removes every unnecessary space and line break:
{"name":"FileTools Kit","tools":["merge-pdf","text-diff"]}
Both are identical to a program. Pretty-print to read, debug, or review. Minify to save space when storing JSON, sending it in a request, or pasting it into a field with a length limit.
Format, minify, and validate in Dev Tools
- Open Dev Tools and stay on the JSON / CSV tab.
- Paste your JSON into the JSON Input / Output box, replacing the sample.
- Press Format JSON to pretty-print it with two-space indentation, or Minify JSON to put it on one line.
- If the JSON is invalid, the box is left as it is and an error appears, starting with "Invalid JSON:" followed by your browser's parser message. Most browsers include a position, such as "at position 57" or "line 3 column 5", which points you to the problem.
- Fix the error, press Format JSON again, and copy the result.
Formatting checks validity at the same time. If Format JSON succeeds, the text is valid JSON.
The mistakes that break JSON
Almost every invalid JSON file has one of these problems:
- Trailing commas. {"a": 1, "b": 2,} fails because of the comma before the closing brace. JavaScript allows it; JSON does not.
- Single quotes. {'name': 'Asha'} fails. Strings and keys must use double quotes.
- Unquoted keys. {name: "Asha"} fails. Keys are always quoted strings.
- Comments. // and /* */ are not allowed in standard JSON. Some config formats such as JSONC allow them, but a strict parser will not.
- Special values. undefined, NaN, and Infinity are not valid. Use null.
- Unescaped characters in strings. A double quote inside a string must be written \" and a backslash as \\. Windows paths are a common culprit: "C:\Users" should be "C:\\Users".
- Smart quotes. Copying JSON from a word processor or chat app can turn " into curly quotes, which are not valid. Retype them or paste through a plain text editor.
- Missing commas between items after editing by hand.
When the error points to a position, look just before it. The parser usually notices a problem one character after the real mistake.
Reading API responses
When you copy a response from your browser's network tab, a log file, or a support ticket, it is usually minified. Paste it into Dev Tools and press Format JSON to see its structure. Look for the field you need by its key, and check whether a value is a string ("42") or a number (42), because code often treats those differently.
Converting JSON to a spreadsheet
If the JSON is an array of flat objects, such as a list of users with the same fields, Convert JSON to CSV on the same tab turns it into rows you can open in Excel or Google Sheets. The CSV and JSON guide explains the limits.
A worked example
Say a colleague sends this and your app refuses to load it:
{"user": "asha", "roles": ['admin', 'editor'], "active": true,}
Paste it into Dev Tools and press Format JSON. The error points near the first single quote. Replace the single quotes with double quotes and press Format JSON again. Now the error points at the closing brace, because of the trailing comma after true. Remove that comma and the JSON formats cleanly into eight readable lines. Fixing errors one at a time like this, letting the parser point at each, is faster than reading the whole file by eye.
Privacy
API responses often contain email addresses, tokens, and internal IDs. Dev Tools parses and formats JSON in your browser tab with the built-in JSON parser. Nothing is sent to FileTools Kit. Even so, remove access tokens and API keys before you paste JSON anywhere, including tools you trust, and never share them in screenshots.
FAQ
Can I choose four-space indentation?
No. Format JSON uses two spaces, which is the most common convention.
Does formatting change my data?
No. Only spacing changes. One subtle exception: if an object has the same key twice, the parser keeps the last value, so the formatted output will contain only one.
Why does my number look different after formatting?
Very large integers beyond about 9 quadrillion lose precision in JavaScript. APIs that use such IDs usually send them as strings for this reason.
Is JSON the same as a JavaScript object?
Similar, but stricter: double quotes only, no trailing commas, no comments, no functions.
Related guides: convert CSV to JSON and back, Base64 explained, compare two versions of a text.
Written by Souren Das, FileTools Kit, Bengaluru. Last updated 10 October 2026. Spotted a mistake or a step that does not match the tool? Email support@filetoolskit.com and I will fix it. See how tools and guides are tested.