What Is a JSON File? Data Types, Example, How to Open
What is a JSON file? A plain text format for structured data built from objects and arrays. See the six data types, a real example and how to open one.
Updated
A JSON file is a plain text file that stores structured data as nested objects and arrays, using a syntax borrowed from JavaScript. JSON stands for JavaScript Object Notation; files use the .json extension and the media type application/json. It is the default format for web APIs and a great many configuration files because it is easy for people to read and trivial for programs to parse.
What JSON looks like
Here is a complete, valid JSON document:
{"id": 42, "name": "Ada Lovelace", "active": true, "manager": null, "tags": ["admin", "beta"], "address": {"city": "London", "postcode": "W1"}}
Read it left to right. The outer curly braces make an object, which is a set of key and value pairs. "id" is a key and 42 is its value. "tags" holds an array, written with square brackets. "address" holds another object, nested inside the first. Nesting can go as deep as you need, which is what lets JSON describe things a flat table cannot.
Spaces and line breaks between tokens do not matter. The same data can be written on one line, as above, or spread over many indented lines. Servers usually send the compact form to save bytes; people prefer the indented form.
The six data types
Every JSON value is one of exactly six types:
| Type | Example | Notes |
|---|---|---|
| String | "hello" | Always double quotes. Special characters use backslash escapes such as \n and \" |
| Number | 42, -3.14, 1.5e10 | No quotes. No leading zeros, no hex, no NaN or Infinity |
| Boolean | true, false | Lowercase only |
| Null | null | Lowercase. Means "no value" |
| Object | {"a": 1} | Unordered pairs. Keys must be double-quoted strings |
| Array | [1, "two", null] | Ordered list. Items can be of mixed types |
That is the whole type system. There is no date type, so dates travel as strings, usually in ISO 8601 form such as "2026-11-17T09:30:00Z", or as numbers holding a Unix timestamp. There is no separate integer type either. JSON itself puts no limit on number size, but many parsers read numbers as 64-bit floats, which hold integers exactly only up to 9,007,199,254,740,991. That is why APIs often send large IDs as strings.
A JSON document is a single value. Most often the top level is an object or an array, but a lone string or number is valid too.
The syntax rules that trip people up
JSON looks like a JavaScript object literal, but it is stricter:
- Keys must be in double quotes.
{name: "Ada"}is JavaScript, not JSON. - Strings use double quotes only. Single quotes are invalid.
- No trailing commas.
[1, 2, 3,]fails. - No comments of any kind.
- No
undefined, no functions, no dates. - Line breaks inside a string must be written as
\n, not as a real new line.
Break any of these and a parser rejects the entire file, not just the bad line. The separate guide on how to format and validate JSON walks through the error messages and how to fix each one. For the backslash sequences allowed inside strings, see escape characters explained.
Where JSON came from
Douglas Crockford popularized the format in the early 2000s as a lightweight way for browsers and servers to exchange data without XML. It is now specified by two matching documents: RFC 8259, published in 2017, and the ECMA-404 standard. RFC 8259 also requires UTF-8 encoding when JSON is exchanged between systems, so a JSON file can hold text in any language, emoji included.
Although the syntax comes from JavaScript, JSON is language independent. Python, Java, Go, C#, PHP, Ruby, Rust and Swift all ship with or have standard libraries for reading and writing it.
How to open a JSON file
A JSON file is text, so you never need special software to see what is inside:
- Text editor. Notepad on Windows and TextEdit on macOS will open any
.jsonfile. A code editor such as VS Code adds color and can fold nested sections; its Format Document command indents the file. - Web browser. Drag the file into Firefox and it displays a collapsible tree with a filter box. Chrome and Edge show the raw text.
- Online formatter. If the file is one enormous line, paste it into the JSON Formatter. It indents the structure with two or four spaces, or reports the parser's error message if the content is not valid JSON.
- Command line.
python3 -m json.tool data.jsonpretty-prints a file with nothing extra installed. If you havejq,jq . data.jsondoes the same with color, andjq .address.city data.jsonpulls out a single value.
In code, reading JSON is a one-liner: JSON.parse(text) in JavaScript, json.load(file) in Python. Writing it is JSON.stringify(value, null, 2) and json.dump(value, file, indent=2).
If double-clicking a .json file does nothing useful, that is because your system has no default app for the extension. Right-click it, choose Open with, and pick a text editor.
How to read a large JSON file
Start from the outside. Check whether the top level is { (one object) or [ (a list of things). If it is an array, look at the first element only; the rest almost always have the same shape. Then note the keys at each level and ignore the values until you find the part you need.
Indentation does most of the work here, which is why formatting first is worth the few seconds. Once you know the path to a value, for example orders[0].items[2].price, you can pull it out in code or with jq.
JSON describes data, not behavior. A JSON file cannot run code, so opening one in a text editor or a formatter is safe. The risk only appears when a program trusts the values inside without checking them.
JSON and other formats
JSON is one of several text formats for structured data, and conversions between them are common:
- Tabular data such as a list of records fits CSV, which spreadsheets open directly. The JSON to CSV Converter turns an array of objects into rows and columns. See what a CSV file is for that format's rules.
- Configuration that people edit by hand is often written in YAML, which allows comments. YAML vs JSON compares the two.
- Older enterprise systems and document formats use XML. JSON vs XML shows the same data in both.
JSON's niche is the middle ground: structured enough for nested data, simple enough that every language reads it the same way.
Try it
Paste the contents of any .json file into the JSON Formatter to see it indented and to confirm it is valid. Switch to Minify to get the compact single-line version for a request body or an environment variable.