JSON GUIDE · 4 MIN READ
JSON syntax, with practical examples
Write valid strings, numbers, objects, arrays, booleans, and null without JavaScript-only syntax.
Write one complete value
Use double quotes around both strings and object property names. Separate members and array elements with commas, but leave off the final comma. Lowercase true, false, and null are values; quoted versions are strings.
A number may have a minus sign, fractional part, or exponent. A leading plus, a leading zero in a multi-digit integer, NaN, and Infinity are not strict JSON. Dates and identifiers should be strings when their exact text matters.
{
"message": "Hello\nworld",
"temperature": -2.5,
"samples": [0, 1e3],
"ready": false
}Check the receiving program too
Comments, single quotes, and unquoted keys can be accepted by some configuration formats but fail a strict JSON parser. Use the JavaScript data conversion tool only when you intentionally have supported JSON5-style input.
Syntax-valid numbers can still exceed a consumer's numeric precision. Encode long identifiers as strings at the source, rather than trying to repair them after a parser has rounded them. When an error points to a closing brace, inspect the preceding member for a missing comma or unfinished string.
Put it into practice
JSON Validator
Check strict JSON syntax and locate malformed values before using your data.
JavaScript Data to JSON
Convert safely parsed JSON5-style data such as single-quoted strings and unquoted keys.
JSON String Escape
Encode text as a quoted JSON string with valid escapes for quotes and newlines.

