Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

JSON (JavaScript Object Notation) is a lightweight, text-based, language-independent format for serializing structured data. It represents values with objects, arrays, strings, numbers, booleans and null. JSON is data, not a programming language: it has no comments, functions, dates or schema rules built into its syntax.

This guide explains the grammar, common validation failures, dates and other richer values, HTTP usage, safe parsing, interoperability traps and practical debugging techniques.

What JSON is—and what it is not

RFC 8259 defines JSON as a lightweight, text-based, language-independent data interchange format. ECMA-404 defines the syntax only; it does not define what a field means, which fields are required, or how a programming language should map a value internally. Those semantics belong to an API contract, schema or application agreement.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A JSON text may contain an object, array, number, string, true, false or null at the top level. Whitespace around structural characters is insignificant, so these two documents carry the same value:

{"ok":true,"count":2}
{ "ok": true, "count": 2 }

JSON is commonly used in HTTP APIs, configuration files, queues and logs because independent languages can parse the same text.

Which data types does JSON support?

Type Example Important rule
Object {"name":"Ada"} A collection of name/value pairs. Every property name is a double-quoted string.
Array ["red","green"] An ordered sequence of JSON values; values may have different types.
String "hello" Must use double quotes. Escape characters such as quotation marks and backslashes.
Number -12.5 Uses JSON decimal syntax. JSON does not promise a particular machine precision or integer range.
Boolean true or false Lowercase only.
Null null Represents an explicitly absent or empty value.

Functions, regular expressions, maps, sets, undefined, NaN and Infinity are not JSON values. A producer must convert them to an agreed representation before serialization.

What syntax makes JSON valid?

Objects and property names

Use braces for objects, a colon between each name and value, and commas between members. Names must be enclosed in double quotes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
{"user_id":42,"active":true,"roles":["admin","editor"]}

{user_id: 42} is JavaScript object-literal syntax, not valid JSON, because the property name is unquoted.

Arrays and commas

Use brackets for arrays. A comma separates values, but a trailing comma is forbidden:

[1,2,3]
[1,2,3,]

The second example is invalid even though many programming languages accept it.

Strings and literals

JSON strings require double quotes; single quotes are not interchangeable. The only literal keywords are lowercase true, false and null. Comments are not part of the grammar.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Invalid text Why it fails Valid form
{'name':'Ada'} Single-quoted strings {"name":"Ada"}
{name:"Ada"} Unquoted property name {"name":"Ada"}
{"total":1,} Trailing comma {"total":1}
{"total":NaN} JavaScript-only value Use null or a documented string/number convention.
/* note */ {"ok":true} Comments are not allowed Remove the comment or store the note in a property.

How should dates and richer values be represented?

JSON has no native date, time, regular-expression, function, map or set type. Choose a convention at the application boundary and document it. A common approach is a string using an agreed ISO 8601 or RFC 3339 profile; another is a number such as an epoch value. The grammar itself does not tell a consumer how to interpret either.

{"created_at":"2026-09-29T14:30:00Z"}

Whichever convention you choose, specify timezone rules, accepted precision and validation behavior in the API contract. Do not assume that a field named date will be interpreted consistently by every client.

How do schemas and meaning fit in?

Base JSON syntax only answers whether a document is grammatically valid. A schema can define required properties, allowed types, ranges, formats and compatibility policy. JSON Schema and similar specifications are separate from JSON itself, so publish the schema version alongside the API contract and validate incoming data before business logic uses it.

For example, syntax permits an empty object, but an application schema might require id and email. Conversely, syntax permits mixed array values while a schema may restrict an array to numbers.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What MIME type and file extension should developers use?

Send JSON over HTTP with the application/json media type, normally in the Content-Type header. The conventional file extension is .json.

Content-Type: application/json

When a client sends JSON, also set an appropriate charset policy in the API documentation and make sure the server rejects a body that does not match the declared format.

How should JSON be parsed safely?

Parse untrusted text with a dedicated JSON parser. Never pass it to JavaScript eval() or an equivalent evaluator: executable code can accompany data declarations, creating a code-execution risk. Parsing is only the first boundary; apply schema validation, authorization checks and resource limits afterward.

JavaScript

const text = '{"id":42,"active":true}';
const value = JSON.parse(text);
if (typeof value.id !== 'number') throw new Error('id must be a number');
const output = JSON.stringify(value);

Python

import json

text = '{"id": 42, "active": true}'
value = json.loads(text)
if not isinstance(value.get('id'), int):
    raise ValueError('id must be an integer')
print(json.dumps(value))

Use parser limits for maximum body size, nesting depth, array length and processing time where your platform supports them. These controls reduce denial-of-service risk from huge or deeply nested inputs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Interoperability traps developers should specify

Duplicate object names

JSON describes name/value pairs but does not give every implementation the same behavior for duplicate names. One parser may keep the first value, another the last, and another may reject the document. Treat duplicate names as invalid at your boundary or define and test a single policy across all consumers.

Object order versus array order

Arrays preserve order. Do not rely on object member order unless your application contract explicitly defines it and every implementation is tested against that contract.

Number precision and range

JSON syntax allows decimal numbers, but languages differ in exact integer range and floating-point precision. If identifiers or monetary values can exceed a consumer’s exact range, transmit them as documented strings or use a precise numeric representation agreed by every participant. Validate before converting.

Top-level values

RFC 8259 permits any JSON value at the top level, including a string, number, boolean or null. Some older tools expect an object or array, so check the specific API contract rather than assuming a top-level shape.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Inspecting and debugging JSON in a browser

For a web API you control, the browser is enough to find most failures:

  1. Open Developer Tools and select the Network panel.
  2. Reload the page or repeat the request.
  3. Select the request and verify the response Content-Type is application/json.
  4. Open the response or preview tab and copy the exact body, not a visually formatted snippet.
  5. Run that text through a standards-compliant parser. The parser’s line and column usually identify the first structural error.
  6. Check the request payload separately; a valid response does not prove that the request body was valid.

For command-line inspection, save the response bytes and parse them with your language’s JSON library. Avoid “fixing” a document by blindly replacing all apostrophes or commas; those characters may be legitimate string content.

Common errors and precise fixes

Symptom Likely cause Fix
“Unexpected token ‘” Single-quoted string Use double quotes around every JSON string and property name.
“Unexpected token }” Trailing comma or missing value Remove the final comma and check each colon has a value.
Parser stops at a comment Comment syntax was included Remove comments or represent the note as data.
Boolean or null rejected True, False or None from a language runtime Serialize with the JSON library; do not hand-copy language literals.
Large integer changes after parsing Consumer precision limit Transmit the identifier as a string or choose a precision-safe contract.
Valid syntax, rejected request Schema, required field, authorization or media-type failure Inspect the API contract and response status; syntax validation alone is not semantic validation.
Memory or timeout spike Oversized or deeply nested input Enforce body, depth and collection limits before full processing.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, reliability and cost considerations

JSON’s text representation is easy to inspect and portable, but payload size, parsing CPU and memory are operational concerns. Keep responses bounded, paginate large collections, avoid unnecessary repeated fields and reject bodies above a documented limit. For high-volume systems, measure serialization and parsing time in the actual languages and data shapes you use; standards do not provide a universal performance guarantee.

Reliability comes from explicit contracts: pin the schema version, define date and number conventions, test duplicate-name handling, and treat malformed input as a normal error path. A cache or retry layer must not turn a partially received body into a valid-looking document.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Or skip the browser setup

If the page you need to inspect is a web response and you want a clean visual capture, ScreenshotNeo provides a single-call website screenshot API. It accepts cookie and consent banners before capture, removes more than 60 known consent platforms plus newsletter popups and chat widgets, and lets you turn each cleanup step off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed; response headers identify the page verdict and whether it was billed.

Use the API directly (the full option reference is in the ScreenshotNeo documentation):

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo also supports full-page and element captures, device presets and custom viewports, dark mode, retina scale, PDF output, custom CSS and JavaScript, selector waits, network-idle waits, request blocking, headers, cookies, user agents, timezone and geolocation, transparent backgrounds, resizing, selectable cache TTLs, signed links, asynchronous webhooks, bulk capture of up to 100 URLs per call, usage reporting and an OpenAPI specification. An MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients.

The Free plan includes 1,000 screenshots each month with no card. Paid plans start at $5 for 3,000 shots; every feature is available on every plan. Sign up for the free plan.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Does JSON require an object at the top level?

No. RFC 8259 allows any JSON value at the top level, although an individual API may impose an object-or-array requirement.

Who decides whether two JSON fields are backward compatible?

The communicating application and its schema or API contract decide compatibility; JSON syntax itself defines neither required fields nor migration rules.

Can two parsers legally produce different results from the same object?

They can if the document contains duplicate names or relies on unspecified member ordering. Avoid those ambiguities or enforce one tested policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.