JSON for APIs · reviewed November 2026

JSON for API Developers: The Rules, the Usual Mistakes, and a Free Validator

Almost every web API sends and receives JSON, and a single stray comma makes a whole request fail. This page sums up what the JSON standard allows, lists the mistakes that cause most parse errors, and offers a validator that runs in your browser, shows the line and column of a fault, and can format or minify the text.

What the JSON standard allows

JSON is defined in RFC 8259, which matches ECMA-404. A JSON text is built from a small set of pieces: two structures, objects and arrays, and four primitive types, which are strings, numbers, booleans and null. A value may be an object, an array, a number, a string, or one of the three literal names true, false and null.

PieceWritten asRule from RFC 8259
Object{"name": value}Names are strings in double quotes, and a colon separates a name from its value. Names should be unique inside one object.
Array[1, 2, 3]An ordered list of values separated by commas.
String"text"Starts and ends with a double quotation mark.
Number-12.5e3Decimal digits only. Leading zeros are not allowed, and neither are NaN and Infinity.
Literaltrue false nullLowercase only.

Source: IETF RFC 8259, The JavaScript Object Notation (JSON) Data Interchange Format, sections 2 to 7.

The standard has no comment syntax and no trailing comma. Editors that accept them are reading a looser dialect, such as JSON5 or JSONC, and a strict API parser will reject that text.

Six mistakes behind most parse errors

MistakeBroken textFix
Trailing comma{"a": 1,}Delete the last comma.
Single quotes{'a': 1}Use double quotes for names and strings.
Unquoted name{a: 1}Put the name in double quotes.
Comment{"a": 1 // note}Remove it; JSON has no comments.
Bad number{"a": 007}Remove leading zeros, or quote the value if it is an identifier.
Missing value{"a": undefined}Use null, or leave the field out.

Two quieter problems do not stop a parser. Duplicate names in one object are allowed by the grammar, but RFC 8259 says the behavior is unpredictable, and most parsers keep the last one. Very large or very precise numbers can lose precision when a program reads them as 64-bit floating point, which the RFC also warns about.

JSON validator, formatter and minifier

Paste some JSON, then choose a button.

Method: your browser's own JSON parser checks the text, so nothing is sent anywhere and nothing is stored. The line and column come from the parser's message, which differs a little between browsers, so treat them as a pointer. Depth counts nested objects and arrays, and the key count includes keys at every level. Formatting uses two spaces.

Handling API keys and the OWASP API Top 10

Sending JSON is only half of using an API. The other half is keeping your credentials safe. These habits are general good practice, not rules from one provider.

The OWASP API Security Top 10 (2023 edition) lists the main risks that API owners face. Reading it helps you judge what a well-run API should protect.

ItemRisk
API1:2023Broken Object Level Authorization
API2:2023Broken Authentication
API3:2023Broken Object Property Level Authorization
API4:2023Unrestricted Resource Consumption
API5:2023Broken Function Level Authorization
API6:2023Unrestricted Access to Sensitive Business Flows
API7:2023Server Side Request Forgery
API8:2023Security Misconfiguration
API9:2023Improper Inventory Management
API10:2023Unsafe Consumption of APIs

Source: OWASP API Security Top 10, 2023 edition.

Frequently asked questions

Can JSON contain comments?

No. The JSON grammar in RFC 8259 has no comment syntax, so a strict parser rejects them. Tools that allow comments use a related format, such as JSONC or JSON5.

Why does my JSON fail with a trailing comma?

A comma in JSON separates two values or two members, so a comma after the last item has nothing to separate. Remove it and the text parses.

Are single quotes allowed in JSON?

No. Strings and member names must start and end with a double quotation mark. Single quotes work in JavaScript source but not in JSON.

Is it safe to paste API responses into this validator?

The check runs in your browser and the page makes no network request with your text. Even so, remove secrets such as keys and tokens from anything you paste into any tool, as a habit.

About this site

iapi.click is an independent informational site about working with web APIs. It is not an integration platform, it connects to no service and it has no accounts or plans. The rules come from IETF RFC 8259 and the security list from OWASP, each named where used. Last reviewed: November 2026. Educational content, not professional advice.