Atomic Mail
Products
↓
Atomic VPN
Private VPN service
Atomic Mail
Secure encrypted email
Atomic Bot
One-click AI agent runner
Atomic Chat
Local & open-source AI super chat
Atomic Wallet
Secure, anonymous crypto wallet
Sigma Browser
Private AI browser
Atomic Agent
Local-first AI agent
How it worksUse casesCompareFAQBlog
Docs
Login
Blog
/
What Is JSON? Format, Syntax Rules, and Examples

What Is JSON? Format, Syntax Rules, and Examples

Guides
9 min read
Mary Atomic
CMO
September 25, 2026
What Is JSON? Format, Syntax Rules, and Examples
Share this post
Copied!

JSON (JavaScript Object Notation) is a lightweight text format for structuring data as nested key-value pairs – the format almost every modern API, config file, and AI tool-calling system uses to pass information back and forth. It reads like a plain-language list of facts, which is exactly why both humans and machines parse it easily.

TL;DR
  • JSON structures data as key-value pairs, using six value types: strings, numbers, booleans, arrays, objects, and null.
  • It was popularized by Douglas Crockford in the early 2000s, standardized in RFC 8259 and ECMA-404, and has since replaced XML as the default format for most web APIs.
  • Syntax rules are strict but small: double quotes only, no trailing commas, no comments – which is what makes it so easy to parse reliably across every language.
  • JSON.parse() turns a JSON string into a usable object; JSON.stringify() does the reverse – the two functions most JavaScript code needs to work with it.
  • It isn't the most compact format (CBOR and Protocol Buffers beat it on size), but it's small enough and readable enough to have become the universal default anyway.

The JSON Format: Syntax Rules

JSON's syntax is deliberately small – a handful of rules cover the entire format:

  • Six value types, nothing else. A JSON value is always one of: a string ("text"), a number (42 or 3.14, no separate integer/float types), a boolean (true/false), an array (an ordered list, [1, 2, 3]), an object (unordered key-value pairs, {"key": "value"}), or null (an explicit "no value," distinct from an empty string or zero).
  • Keys and strings use double quotes only. Single quotes aren't valid JSON, even though they're common in JavaScript itself – {'key': 'value'} is not valid JSON, {"key": "value"} is.
  • No trailing commas. [1, 2, 3,] is invalid; the comma after the last item breaks strict parsers, which is a common source of "unexpected token" errors when hand-editing a file.
  • No comments. JSON has no // or /* */ syntax at all – Crockford removed comments from the spec deliberately (more on why below).
  • Keys are always strings. Even numeric-looking keys ({"1": "first"}) are quoted strings, never bare numbers.

A .json file uses that extension and is served over the web with the MIME type application/json.

A JSON Object, in Practice

json
{
  "name": "Alex Rivera",
  "age": 34,
  "is_active": true,
  "middle_name": null,
  "labels": ["billing", "urgent"],
  "address": {
    "city": "Austin",
    "zip": "78701"
  }
}

This one example shows all six value types at once: a string (name), a number (age), a boolean (is_active), null (middle_name, meaning the field exists but has no value), a JSON array (labels), and a nested object (address). That's the entire vocabulary of the format – everything else is just these six types nested inside each other.

Reading and Writing JSON in Code

In JavaScript, two built-in functions handle the whole conversion between a JSON string and a usable object:

javascript
const jsonString = '{"name": "Alex", "age": 34}';

// String → object
const data = JSON.parse(jsonString);
console.log(data.name); // "Alex"

// Object → string
const backToString = JSON.stringify(data);

JSON.parse() takes a JSON-formatted string (say, an API response) and turns it into a real JavaScript object you can work with – data.name, data.age, and so on. JSON.stringify() does the reverse: it takes an object in memory and turns it into a JSON string, ready to send over the network or save to a file. Every other language has an equivalent pair (Python's json.loads()/json.dumps(), for example) – the format is the same, only the function names differ.

A Short History

JSON wasn't designed by a committee first and adopted later – it was noticed. Douglas Crockford specified and popularized it in the early 2000s as a lightweight alternative to XML for JavaScript applications, describing it as a subset of the object literal syntax already built into the JavaScript language – which is exactly why it needed no new parser to catch on. It became a formal standard later: RFC 8259 (IETF, 2017) and ECMA-404 (Ecma International) both define the same format, so "JSON" today means one precise, standardized thing rather than a loose convention.

JSON vs. XML

JSON XML
Syntax {"key": "value"} <key>value</key>
Data types Six native types (string, number, boolean, array, object, null) Everything is text – no native number or boolean type
Arrays Native ([1, 2, 3]) No native array – represented as repeated elements
Typical file size for the same data Smaller – less markup overhead Larger – opening and closing tags around every value
Schema validation JSON Schema (optional, less universal) XML Schema (XSD), a mature and widely-adopted standard
Parsing in a browser Built into every JS engine (JSON.parse) Also built in (DOMParser) – not something you need a separate library for either
Supports comments No – removed deliberately (see below) Yes
Common use today Web APIs, config files, AI tool calls Document formats (Office XML, RSS), some legacy enterprise systems, SOAP APIs

The "no comments" row has a specific story behind it: Crockford has explained that he removed comments from JSON on purpose, because he saw them being misused by some parsers as processing directives – which would have broken interoperability between different JSON implementations. The trade-off was intentional: a stricter, more uniform format over a more convenient one.

Where JSON Shows Up

JSON isn't tied to any one kind of software – it's the default shape for structured data almost everywhere:

  • Config files. package.json, tsconfig.json, VS Code settings – JSON is the default format for project configuration across most modern tooling, because it's easy to diff, easy to validate, and every language can parse it.
  • Mobile and web app state. A shopping cart, a user's saved preferences, a game's leaderboard – all typically travel between a client and a server as JSON, whether it's cached locally or synced through an API.
  • IoT and sensor data. A smart thermostat or a fleet-tracking device often reports its readings as small JSON payloads – not because JSON is especially compact (formats like CBOR and Protocol Buffers are built specifically to be smaller and faster to parse), but because it's small enough for constrained devices while staying human-readable for debugging.
  • AI tool-calling. When a model calls a tool – a search, a calculator, a database query – the function arguments and the result are JSON, because a JSON schema is simple enough for a model to generate reliably and simple enough for code to validate before acting on it.

Why This Matters for AI Agent Email

One specific corner of that last case is worth calling out: an AI email agent calling an email API built for agents lives or dies on how clean that JSON comes back. A good API returns already-parsed fields – subject, from, body, threadId – instead of raw MIME text the agent has to decode itself. Atomic Mail Agentic returns structured JSON for every mail operation for this reason – an agent gets real fields to reason over immediately, not a raw message to parse first.

Give your agent a real inbox
Structured JSON for every mail operation. Free while in open alpha.
Get started →

FAQ

Is JSON only for web development? No – it's used for config files, logs, data storage, and increasingly as the default format AI systems use to talk to tools and APIs of any kind.

What's the difference between JSON and a JavaScript object? A JavaScript object is a live structure in running code; JSON is its text representation – a string format for storing or sending that same shape of data, usable from any language via JSON.parse()/JSON.stringify() or their equivalents, not just JavaScript.

What is the difference between JSON and XML? JSON uses key-value pairs with native data types and less markup; XML uses nested tags where every value is text, with a more mature schema-validation ecosystem. JSON is generally smaller and easier to parse; XML supports comments and has stronger tooling for document-style data.

Is JSON the same as SQL? No – they solve different problems entirely. SQL is a language for querying and managing data inside a relational database; JSON is a data format for structuring and exchanging data between systems. A database can store JSON documents, and a SQL query can even return results formatted as JSON, but one is a query language and the other is a data format.

Which is better, HTML or JSON? They're not interchangeable, so "better" depends on the job: HTML structures content for a web page a human reads in a browser; JSON structures data for two programs to exchange without any visual rendering involved. A weather app's data comes as JSON; the page displaying it is HTML.

Is JSON a coding language? No – JSON is a data format, not a programming language. It has no functions, loops, or logic of its own; it only describes data, which is then read and acted on by code written in an actual programming language.

Why did JSON largely replace XML for APIs? Less markup for the same data, native parsing in every major language, and a syntax simple enough that both humans and language models produce it correctly without heavy tooling.

Does the email API I use actually matter if it all returns JSON eventually? Yes – whether an API returns already-structured JSON or a raw message a client has to parse is the difference between an agent acting in one step and an agent (or a developer) writing a parsing layer first.

‍

Posts you might have missed

Best Email APIs 2026
Comparisons
13 min read

Best Email APIs 2026

Every email API sends well. Almost none let your agent receive. Here's what breaks, and how the free tiers actually compare in August 2026.
Read more
Build an AI Email Agent With Its Own Inbox in 30 Seconds (No Gmail, No OAuth, No Domain)
Guides
8 min read

Build an AI Email Agent With Its Own Inbox in 30 Seconds (No Gmail, No OAuth, No Domain)

Give an autonomous AI agent its own email inbox in about 30 seconds — no Gmail, no OAuth, no domain. A runnable guide: register, send, receive, and reply over JMAP.
Read more
Top 5 A2A Services 2026
Comparisons
10 min read

Top 5 A2A Services 2026

Two agents, different companies, no shared cloud. Five services that actually connect them, ranked — and how to pick one.
Read more
Go through all posts

Product

How it worksUse casesCompareFAQDocumentationBlogEmail for humans

Compare to

AgentMailResendSendGridOpenMailHostingerNylas Mailtrap

Policies

Terms of UsePrivacy Policy
support@atomicmail.ai
Atomic Mail Agentic - Let your agents read, send, and react to email autonomously | Product Hunt

ATOMICMAIL SYSTEMS OÜ.
HARJU MAAKOND, TALLINN, KESKLINNA LINNAOSA, HARJU TN 3 // VANA-POSTI TN 2, 10146

© 2026 ATOMIC MAIL