JSON (JavaScript Object Notation) is the most common format for exchanging data between web services, apps and configuration files. It is text based, easy for people to read and supported by practically every programming language.
The building blocks
JSON has only a few types: objects in curly braces with "key": value pairs, arrays in square brackets, strings in double quotes, numbers, true, false and null. Everything else, such as dates, is written as a string or number by agreement.
The most frequent errors
- Trailing commas after the last item of an object or array are not allowed.
- Keys and strings must use double quotes. Single quotes are invalid.
- Comments are not part of the standard.
- Unescaped line breaks and quotes inside strings break the parser.
- Numbers cannot have leading zeros, and values such as NaN or undefined do not exist.
A formatter and validator points to the exact position of the problem and shows the structure with indentation, which is far easier than reading one long line.
Format or minify?
Pretty-printed JSON with indentation is for people: use it while you debug, review a response or store configuration in a repository. Minified JSON removes all optional whitespace and is meant for machines, since it makes a request or file smaller. The content is identical either way, so you can switch back and forth without losing anything.
Converting to other formats
Spreadsheets and databases usually work with tables, while APIs return nested objects. Converting between JSON and CSV helps to open API data in a spreadsheet or to import a table into an application. Be aware that nested structures must be flattened for CSV, and that CSV has no types, so numbers and text can be confused.
Tips for developers
- Validate data at the boundary where it enters your application.
- Do not put secrets, such as access tokens, into JSON you paste into online tools unless the tool states that it runs locally.
- Use consistent key naming (camelCase or snake_case) across an API.
The JSON tools on this site run in your browser, so the text you paste stays on your device.
Types and the surprises they cause
JSON has only six kinds of value: strings, numbers, booleans, null, arrays and objects. That simplicity is its strength, yet a few details regularly cause bugs:
- JSON has no date type. Dates are usually strings in ISO 8601 form, such as 2026-03-14T09:30:00Z. Parsers will not convert them for you unless told to.
- Numbers have no declared size. In JavaScript, integers above 9,007,199,254,740,991 lose precision, so large database identifiers are often safer as strings.
- null is different from a missing key. In an API update, sending null may mean "clear this value" while leaving the key out means "do not change it".
- Key order is not meaningful. Do not write code or tests that depend on keys appearing in a particular order.
Reading long JSON effectively
Real API responses can run to thousands of lines. A few habits help:
- Format the document before you read it, and collapse the sections you do not need.
- Find the shape first. Is the top level an object or an array? Where is the list of records?
- Inspect one record carefully before writing code that handles thousands.
- Note which fields can be null or absent, because those are the ones that crash production code.
When an error message reports a line and column, look at the line before it as well. A missing comma is usually reported at the start of the following item, not where the comma should have been.
Validating the structure, not just the syntax
A document can be perfectly valid JSON and still be wrong for your application. Syntax checks only confirm that it can be parsed. To check that a field is present, has the right type or falls within an allowed range, projects use JSON Schema or validation code. This matters most at system boundaries: anything received from a browser, a partner's API or an uploaded file should be treated as untrusted until it has been validated.
JSON Lines for logs and large data
Normal JSON has to be read as a single document, which becomes awkward for very large files. JSON Lines, often saved with the .jsonl extension, stores one complete JSON object on each line. A program can process it line by line, append new records cheaply and continue after a single damaged row. It is popular for log files and data exports, but note that a JSON Lines file as a whole is not a valid JSON document.
Comments and trailing commas
Strict JSON does not allow comments or a comma after the last item. Some configuration formats, such as JSONC used by certain editors, are more forgiving, which is why a file that works in one tool can fail in another. If a strict parser complains about a configuration file, look for these two things first.
Be careful with secrets and pasted data
API responses often contain tokens, e-mail addresses and customer records. Before pasting such text into an online service, find out where it is processed. Remove sensitive values from examples you put in bug reports, tickets or documentation, and replace them with realistic fake values. Rotating a leaked key costs far more time than taking a few seconds to clean an example.
Security when parsing
Never use a general code evaluator such as JavaScript's eval to read JSON; use the language's real JSON parser. Be careful when merging parsed objects into existing ones, because specially crafted keys can modify shared objects in some languages. Limit the size of the input you accept, so that a huge request cannot exhaust the memory of your service.