Developer

JSON (JavaScript Object Notation)

A lightweight data interchange format using human-readable text to store and transmit structured objects. It's widely used for web APIs and configuration files.

What JSON is strict about

A JSON value is an object, an array, a string, a number, or one of true, false and null. A whole JSON text can be any of those, not only an object. Strings and keys use double quotes. Single quotes, comments, trailing commas and undefined are errors, and so are NaN and Infinity. Keys inside an object should be unique, because software that gets a repeated key doesn't agree on which one wins.

The parse errors guide lists the usual mistakes, and JSON with comments covers the commented variant that editors accept.

Where numbers lose digits

JSON writes numbers as plain decimal text, and the format itself doesn't cap their size or precision. Software does. Most of it reads numbers as 64-bit floating point, so whole numbers stay exact only up to 9,007,199,254,740,991. Beyond that, doubles skip values. Near 9007199254740993 they sit 2 apart, so JSON.parse followed by JSON.stringify gives back 9007199254740992. Database IDs and 64-bit counters are the usual victims, and the fix is to send them as strings.

Decimals have a milder version of the problem. 1.10 comes back as 1.1, since a number keeps no memory of a trailing zero. For money, send whole cents or a string. The large numbers guide shows how to keep every digit.

Dates, binary data and text

JSON has no date type. Dates travel as strings, usually in ISO 8601 form like 2026-11-11T09:30:00Z, or as Unix timestamps. Binary data has no type either, so it travels as Base64 text, which adds 33% to its size.

Text has to be UTF-8 when JSON moves between systems, so accented letters and emoji can sit in a string as they are. Quotes, backslashes and control characters must be escaped, and any other character can be too, with a \u escape.

Indented or minified

A parser ignores whitespace between tokens, so the same data can be written with indentation for people or on one line for the wire. Indent while you debug and diff. Minify when bytes matter. Minify JSON shows what that changes and saves.

Work it out yourselfOpen the JSON Formatter

Sources

Back to the glossary