Development · Term

JSON

JSON (JavaScript Object Notation) is a simple text format for structured data, written as named fields and lists, that websites, apps and APIs use to exchange information in a way both people and software can read.

JSON is the common language of data on the web. When your site asks an API for the weather, a payment provider confirms a charge or a headless CMS sends a page's content, the data almost always travels as JSON. Despite the name, it is not tied to JavaScript; nearly every programming language can read and write it.

JSON is a format, not a database or a programming language. It describes data but does nothing with it. Owners most often meet it in two places: settings and export files, and the structured data that describes a business to search engines, where it is written as JSON-LD.

How it works

JSON has a small set of building blocks. An object is a set of named fields inside curly braces, each written as a name in double quotes, a colon and a value. A value can be text in quotes, a number, true or false, null for empty, a list inside square brackets, or another object. Nesting these lets JSON describe almost anything, such as an order containing a customer and a list of items, each with a name and price.

The rules are strict. Names must be in double quotes, items are separated by commas, there must be no comma after the last item, and comments are not allowed. A single missing quote or extra comma makes the whole file invalid, and software reading it will usually refuse it entirely rather than guess.

For search engines, JSON-LD is a way of writing schema markup as a block of JSON inside the page. It states facts about the page in a fixed vocabulary, such as the business name, address, opening hours or the questions and answers on the page, which helps Google and other systems understand them without relying on the visible layout.

Example

A bakery's site includes a JSON-LD block describing it as a local business, with its name, street address, phone number, opening hours and a link to its map listing. Visitors never see it, but search engines read it to confirm the details shown on the page.

When the bakery changes its Saturday hours, the owner updates the visible text but forgets the JSON-LD, so the two disagree. Later, someone edits the block by hand and leaves a trailing comma, which makes it invalid. Google's Rich Results Test shows the error immediately, and fixing one character makes the data readable again. The bakery now edits its hours in one place in the CMS, which updates both the visible text and the JSON-LD together.

Why it matters for your business

You do not need to write JSON, but you will meet it. Integrations between your site and other tools pass JSON back and forth, plugin and theme settings are often exported as JSON, and the structured data that supports rich results is usually JSON-LD. The practical skills are knowing that a tiny syntax error breaks a whole file, keeping structured data in step with what the page says, and checking it with Google's free testing tools after any change.

Common mistakes

  • Editing a JSON file by hand and leaving a trailing comma or a curly quote that makes it invalid.
  • Letting JSON-LD say one thing, such as opening hours or prices, while the visible page says another.
  • Putting secrets such as API keys into JSON files that are publicly downloadable from the site.
  • Copying structured data from another site without changing the business details inside it.

Questions people ask

What is the difference between JSON and JSON-LD?

JSON is the general data format. JSON-LD is a way of using JSON to describe linked facts with a shared vocabulary, mainly schema.org on websites. Every JSON-LD block is valid JSON, but it follows extra conventions so that search engines know what each field means.

How do I check if JSON is valid?

Paste it into a JSON validator, many of which are free online, or open it in a code editor that highlights errors. For structured data on web pages, use Google's Rich Results Test or the Schema Markup Validator, which also check the vocabulary, not just the syntax.

Is JSON better than XML?

For most web APIs, JSON is the usual choice because it is shorter and easier to read and work with. XML is still common in older systems, document formats and some feeds and sitemaps. Neither is wrong; it depends on what the receiving system expects.

Related terms

Have something worth building right?