JSON meaning and a first example
JSON stands for JavaScript Object Notation. It was popularised by Douglas Crockford in the early 2000s, borrows its syntax from JavaScript and is standardised as RFC 8259 and ECMA-404. Despite the name, JSON is independent of any programming language: practically every language can read and write it.
A small JSON document describing a person:
{"name": "Ada Lovelace", "born": 1815, "languages": ["English", "French"], "mathematician": true, "spouse": null}
JSON data types
| Type | Example | Notes |
|---|---|---|
| String | "Hello" | text in double quotes, with escapes such as \n |
| Number | 42, -3.14, 6.02e23 | no NaN, Infinity, hexadecimal or leading zeros |
| Boolean | true, false | always lowercase |
| Null | null | an empty or unknown value |
| Object | {"key": "value"} | name/value pairs; the names are strings |
| Array | [1, 2, 3] | an ordered list of values of any type |
JSON has no date type: dates are usually written as ISO 8601 strings such as "2026-05-01T10:00:00Z".
JSON format: the syntax rules
- Data is written as name/value pairs:
"name": "Ada". - Names (keys) and strings always use double quotes – never single quotes.
- Items are separated by commas, with no comma after the last item.
- Curly braces
{ }hold objects, square brackets[ ]hold arrays. - Comments are not allowed.
- Spaces and line breaks between items are ignored, so the same data can be minified or formatted.
- A JSON text contains one top-level value and is encoded in UTF-8.
What is a JSON file?
A JSON file is a plain-text file with the .json extension that contains one JSON document. Its media type is application/json, and it should be saved as UTF-8. Typical JSON files are data exports from apps and websites (for example Google Takeout or social-media downloads), configuration files such as package.json, API responses saved to disk and data sets for analysis. Because it is plain text, a JSON file is safe to open – it cannot run code.
How to open a JSON file
| Where | How |
|---|---|
| Windows | Right-click the file → Open with → Notepad, or use a code editor such as VS Code. Dragging the file into a browser window shows it too. |
| Mac | Open it with TextEdit or a code editor, or drop it onto a browser window. |
| iPhone and Android | Open it from the Files app in a text viewer, or load it into an online JSON viewer – ours works on phones and the file stays on your device. |
| Web browser | Firefox has a built-in JSON viewer; in any browser, an online JSON viewer shows the data as a collapsible tree. |
| Excel | Use Data → Get Data → From File → From JSON on Windows, or convert the file with JSON to CSV first. |
JSON vs XML
| JSON | XML | |
|---|---|---|
| Syntax | braces, brackets, name/value pairs | opening and closing tags |
| Data types | string, number, boolean, null, object, array | text only, unless a schema defines types |
| Size | compact | larger because of closing tags |
| Comments | no | yes |
| Attributes, namespaces | no | yes |
| Typical use | web APIs, configuration, NoSQL databases | documents, office files, SOAP and enterprise systems |
JSON in APIs and applications
Most web APIs send and receive JSON. A client sends a request with the header Content-Type: application/json, the server answers with JSON, and the program turns it into native objects with JSON.parse in JavaScript, json.loads in Python or json_decode in PHP. JSON also powers configuration files such as package.json and tsconfig.json, document databases such as MongoDB, and the structured output of AI models.
Common JSON errors
- A trailing comma after the last item:
[1, 2,] - Single quotes or unquoted keys:
{'a': 1},{a: 1} - Comments such as
// note - A missing comma or bracket between items
- JavaScript or Python values like
undefined,NaNorTrue
Paste your data into the JSON validator to see the exact line and column of the problem, or let Repair fix it automatically.
JSON5, JSONC and JSON Lines
- JSON5 – a more relaxed superset for hand-written files: comments, trailing commas, single quotes, unquoted keys and hexadecimal numbers. Standard JSON parsers cannot read it.
- JSONC – JSON with comments, used for VS Code settings and
tsconfig.json. - JSON Lines / NDJSON (
.jsonl) – one JSON value per line, ideal for logs and streaming large data sets. - GeoJSON – JSON for geographic features, defined in RFC 7946.
Frequently asked questions
Is JSON a programming language?
No. JSON is a data format: it describes data but cannot contain logic, functions or comments.
Is JSON the same as a JavaScript object?
No. JSON is text that looks like a JavaScript object literal, but it is stricter: keys and strings need double quotes, and functions, undefined and comments are not allowed. JSON.parse turns the text into a real object.
How do I create a JSON file?
Write the data in any text editor following the rules above and save it as UTF-8 with the .json extension. Check it with a JSON validator before you use it.
Updated: