
JSON (JavaScript Object Notation) is a lightweight text format for representing structured data. Despite its name, it is language-independent and used everywhere from REST APIs to configuration files. A valid JSON document is either an object (a set of key-value pairs wrapped in curly braces) or an array (an ordered list wrapped in square brackets).
The six value types in JSON are: string, number, boolean (true/false), null, object, and array. Every key in a JSON object must be a string enclosed in double quotes — not single quotes, not unquoted identifiers.
JSON is strict. A single syntax error makes the entire document unparseable. The most frequent mistakes are:
{"name": "Alice",} — the trailing comma after the last item is illegal in JSON (it is valid in JavaScript, which causes confusion).{'key': 'value'} is not valid JSON.{name: "Alice"} is JavaScript object literal syntax, not JSON.null or omit the field.
, not as literal line breaks.JSON sent over a network is often minified — whitespace stripped — to reduce payload size. But JSON stored in configuration files or committed to version control should be formatted for human readability. The standard conventions are:
Most editors can auto-format JSON. In VS Code, right-click and select "Format Document," or use the shortcut Shift+Alt+F. Command-line users can use jq . input.json to pretty-print any JSON file.
JSON itself imposes no naming conventions, but your API or codebase should pick one and stick with it. The three common patterns are:
firstName) — standard in JavaScript APIs and most REST servicesfirst_name) — common in Python APIs and PostgreSQLFirstName) — used in some .NET and C# environmentsMixing conventions in a single API is a source of confusion. If you consume an API with one convention and your codebase uses another, handle the conversion in a dedicated serialization layer rather than spreading ad-hoc conversions throughout your code.
A JSON object can represent the absence of a value in two ways: the key is present with a null value, or the key is absent entirely. These have different semantics. Use null when a field is expected but has no value (e.g., a middle name field that the user left blank). Omit the field when it simply does not apply to that record at all. Decide on a consistent approach within your API so consumers know what to expect.
JSON numbers have no defined size limit, but many parsers deserialize them as IEEE 754 double-precision floating-point values. This means integers larger than 2^53 cannot be represented precisely. If your JSON needs to carry large integers (database IDs, financial amounts in minor currency units, cryptographic identifiers), represent them as strings and document this in your API. This is a well-known gotcha with Twitter's tweet IDs, for example.
Beyond syntax validation (is this valid JSON?), JSON Schema allows you to define the expected shape of a document: which fields are required, their types, value ranges, and more. Tools like ajv (JavaScript), jsonschema (Python), and online validators can check a JSON document against a schema. For any API you publish or consume in a production context, JSON Schema validation is worth implementing at the boundary.
A JSON formatter and validator — like the one on TheDailyUtils — is the fastest way to catch syntax errors in an unfamiliar payload. Paste in the raw JSON, and you'll immediately see whether it parses and where any errors are located.
Open the free JSON formatter — paste any JSON to pretty-print, minify, or catch syntax errors in seconds. Runs in your browser; your data stays private.