A practical guide to JSON
What is JSON?
JSON, short for JavaScript Object Notation, is a text format for exchanging structured data. It represents objects as collections of named properties and arrays as ordered lists. Values can be strings, numbers, objects, arrays, booleans, or null. Although its name refers to JavaScript, programs in many languages can read and write it. A JSON document has one top-level value; that value does not have to be an object.
For example, an API might return an object such as:
{
"name": "Ada",
"active": true,
"roles": ["editor", "reviewer"]
}
Here name is a string, active is a boolean, and roles is an array. Double quotes surround property names and strings. The text "true" is a string, which is different from the boolean true.
Common developer uses
JSON often appears in API requests and responses, application configuration, test fixtures, and messages passed between services. Formatting adds indentation and line breaks so nested data is easier to inspect. Minifying removes unnecessary whitespace and can make a payload smaller; it does not encrypt or change the intended data. Both operations require valid JSON and should preserve its values.
In JSON Bench, paste your document and choose Format JSON or Minify JSON. If parsing fails, the page displays a message and, where available, a line and column. It may offer an automatic fix for some common mistakes. Review the repaired text and repair summary before using the output: a syntactically valid repair may not reflect your original intent.
How to fix common errors
Missing commas between properties or array elements are frequent mistakes. Add a comma between adjacent items, but remove a comma after the last item. Every property name must use double quotes, and each name must be followed by a colon. Single-quoted strings and unquoted names may look familiar from JavaScript, but they are not valid JSON.
Check that every opening brace or bracket has the correct closing partner. Inside strings, escape a double quote as \" and a backslash as \\. Literal line breaks inside a string must be escaped, for example as \n. If the reported position looks correct, inspect the preceding line too: a missing separator can cause an error to appear later.
JSON does not allow comments, NaN, or Infinity. Replace unsupported values with valid data when appropriate. This tool also rejects duplicate object keys to avoid ambiguous results; rename or remove the repeated property. JavaScript numbers have limited precision, so integers outside the safe range are rejected rather than silently changed.
Work carefully with data
Formatting checks syntax, not whether a document follows an API's schema or contains correct business information. Validate required fields separately and test your output with the receiving application. JSON Bench processes input locally in your browser. Avoid sensitive data on untrusted devices and use synthetic examples when troubleshooting production data.