What Is JSON?
JSON (JavaScript Object Notation) is a lightweight, human-readable text format for representing structured data as key-value pairs, arrays, and nested objects. Despite the name, it is entirely language-independent and is the dominant data format for REST APIs, configuration files, and data storage across all modern programming languages.
The One-Line Definition
JSON is a text-based data interchange format defined by RFC 8259 (ECMA-404). It represents structured data using six value types: strings, numbers, booleans, null, objects, and arrays.
A JSON Example
{
"user": {
"id": 42,
"name": "Ada Lovelace",
"email": "ada@example.com",
"active": true,
"roles": ["admin", "editor"],
"metadata": null
}
}JSON Data Types
JSON supports exactly six value types — no more, no less:
| Type | Example | Notes |
|---|---|---|
| string | "Hello, world!" | Must use double quotes. Supports Unicode escape sequences (\uXXXX). |
| number | 42 / 3.14 / -7 / 1e10 | Integer or floating-point. No leading zeros, no NaN, no Infinity. |
| boolean | true / false | Lowercase only. Not "True" or 1/0. |
| null | null | Represents an absent or unknown value. Lowercase only. |
| object | {"key": "value"} | Unordered set of key-value pairs. Keys must be strings (double-quoted). |
| array | [1, "two", true, null] | Ordered list of any JSON values (mixed types are allowed). |
Common JSON Syntax Errors
Because JSON is strict about syntax, small mistakes cause the entire document to fail to parse. These are the errors developers encounter most often:
{"a": 1, "b": 2,}Fix: Remove the comma after the last item. JSON (unlike JavaScript) does not allow trailing commas.
{"a": 'hello'}Fix: Use double quotes: {"a": "hello"}
{a: 1}Fix: Keys must be double-quoted strings: {"a": 1}
{"a": 1 // comment}Fix: JSON has no comment syntax. Remove comments before parsing.
{"a": undefined}Fix: JSON has no undefined type. Use null, omit the key, or encode as a string.
{"a": 007}Fix: Leading zeros are invalid. Use 7 instead of 007.
JSON vs XML
Format or Validate JSON Now
Paste any JSON into SmartDevBox and it is auto-detected, formatted, and validated instantly — no button click. If there is a syntax error, the exact line and column number is reported. Open the JSON Formatter → or JSON Validator →
Frequently Asked Questions
What are the JSON data types?
Six: string (double-quoted), number, boolean (true/false), null, object ({key: value}), and array ([...]). There is no date, undefined, or function type in JSON.
What is the difference between JSON and XML?
JSON is more compact and maps directly to language data structures. XML supports attributes, namespaces, and comments, making it more expressive but more verbose. JSON dominates REST APIs; XML is common in SOAP and configuration files.
Can JSON have comments?
No. Standard JSON (RFC 8259) has no comment syntax. The JSON5 and JSONC formats add comment support but are not valid JSON.
How do I format and validate JSON online?
Paste your JSON into SmartDevBox. It auto-detects JSON input and pretty-prints it immediately. Syntax errors are reported with line and column numbers. 100% client-side — your data never leaves the browser.