JSON (JavaScript Object Notation) is a lightweight text format for storing and sending data. It is used by most web APIs, configuration files, and apps because it is easy for humans to read and easy for programs to parse.
A simple example
json
{
"name": "Ayesha",
"age": 28,
"skills": ["design", "writing"],
"active": true,
"address": null
}The building blocks
- Objects: key-value pairs inside curly braces
{} - Arrays: ordered lists inside square brackets
[] - Values: strings, numbers,
true,false, ornull
Rules that trip people up
- Keys must be in double quotes. Single quotes are not valid JSON.
- No trailing commas after the last item.
- No comments are allowed in standard JSON.
- Strings need double quotes too, and special characters must be escaped.
A common error, fixed
Invalid:
json
{
'name': 'Ayesha',
"age": 28,
}Valid:
json
{
"name": "Ayesha",
"age": 28
}Why formatting matters
API responses often arrive as one long unreadable line. Formatting (also called beautifying or pretty-printing) adds line breaks and indentation so you can see the structure and spot mistakes quickly. The opposite, minifying, strips whitespace to make the file smaller for production.
Format and validate in seconds
Paste your data into a JSON formatter to beautify, minify, and check for syntax errors. If a response contains encoded text, a Base64 converter may help, and a diff checker is useful for comparing two versions of a file.
Good habits
- Use consistent indentation, typically 2 or 4 spaces.
- Validate JSON before sending it to an API.
- Avoid pasting sensitive data, such as API keys or customer records, into tools you do not trust.
- Keep key names consistent, for example always
firstNameor alwaysfirst_name.

