If you've worked with any API — payment gateways like Razorpay, weather APIs, authentication services, or your own backend — you've spent time staring at JSON. Sometimes it's a perfectly structured, readable response. Sometimes it's a single line of minified text with no spaces or newlines, and you're trying to find a missing bracket while your PM asks if the integration is done yet.
A JSON formatter solves the second scenario in about 2 seconds. But understanding JSON properly makes you faster at the first scenario too.
What JSON actually is
JSON stands for JavaScript Object Notation. It's a text format for storing and transmitting structured data — originally derived from JavaScript, now used in virtually every programming language. It replaced XML for most API use cases because it's lighter, easier to read, and natively supported in browsers.
JSON has exactly six data types: strings (always double-quoted), numbers, booleans (true/false, lowercase only), null (lowercase only), arrays, and objects. That's it. The simplicity is why it became the universal API format.
The errors you'll encounter most often
Trailing comma is probably the most common JSON error. {"name": "Ravi", "age": 25,} — that comma after 25 is illegal in JSON. JavaScript allows it, Python allows it, but the JSON spec does not. Every JSON parser will reject it.
Single quotes instead of double quotes. This catches everyone who writes JSON by hand after writing JavaScript or Python all day. {'name': 'Ravi'} is not valid JSON. Keys and string values must use double quotes. Always.
Unquoted keys. {name: "Ravi"} is valid JavaScript object notation but not valid JSON. All keys must be strings, and all strings need double quotes.
Comments. JSON doesn't support comments — no // and no /* */. This surprises people because many config files that use JSON-like syntax (like VS Code's settings.json or tsconfig.json) do support comments via a JSON superset called JSONC. Pure JSON does not.
Unescaped backslashes. If you have a Windows file path in JSON — "C:\Users\Ravi" — that's invalid because \U and \R are not valid escape sequences. It needs to be "C:\Users\Ravi".
Minified vs beautified — when to use each
Minified JSON has all whitespace removed. This is what you should send over APIs — smaller payload, faster transfer. A typical API response that's 50KB beautified might be 35KB minified. At scale, this matters.
Beautified JSON is indented and spaced for humans. This is what you want when debugging, reading API documentation, or reviewing a response to understand its structure. Never try to manually read minified JSON with more than 10 fields — paste it into a formatter first.
Working with JSON in languages commonly used in India
In Python, json.loads() parses a JSON string into a Python dict. json.dumps() converts a Python object back to JSON string. json.dumps(data, indent=2) gives you beautified output.
In JavaScript, JSON.parse() parses a string to object. JSON.stringify() converts an object to string. JSON.stringify(data, null, 2) gives beautified output.
In PHP, json_decode(, true) parses JSON to an associative array (the second parameter is important — without it you get objects). json_encode(, JSON_PRETTY_PRINT) gives beautified output.
In Java, most projects use Gson or Jackson. With Gson: new Gson().fromJson(jsonString, MyClass.class) for parsing, new GsonBuilder().setPrettyPrinting().create().toJson(object) for beautified output.
A specific thing about Indian fintech APIs
Most modern fintech APIs in India — Razorpay, PayU, Cashfree, Setu, NPCI's sandbox — use JSON. But some legacy banking integrations and GST Network (GSTN) APIs still use XML. If you're integrating with a government API or an older banking system, don't assume JSON — check the documentation first. Nothing is more confusing than trying to debug what looks like a malformed JSON response that's actually valid XML.
Paste your JSON into our JSON Formatter & Validator — it highlights errors with line numbers, beautifies or minifies on demand, and runs entirely in your browser with no data sent anywhere.