REZSAT / DEVELOPER WORKFLOW

Why your JSON is invalid: seven errors with working before-and-after examples.

A JSON payload can look perfectly reasonable and still fail in an API. The usual cause is one character in the wrong place—not a complicated server bug. Here is a systematic way to find the difference between a JavaScript-shaped object and valid JSON.

RezSat Editorial2026-11-059 min read

The fastest diagnostic routine

Copy the smallest complete payload that reproduces the error. Run it through a JSON validator and look at the reported parsing failure. Work from the position it identifies, but also inspect the character immediately before it: a missing quote or comma can make the parser complain later than the actual mistake.

When the syntax is valid, pretty-print the JSON to inspect nesting. Validation proves that text follows the JSON grammar; it does not prove that the server accepts the schema, field names or values.

1–3: single quotes, unquoted keys and trailing commas

1. Invalid: {'name':'Maya'}. Valid: {"name":"Maya"}. JSON uses double quotes for both object keys and strings. 2. Invalid: {name:"Maya"}. Valid: {"name":"Maya"}. JavaScript object literal shorthand is not standard JSON.

3. Invalid: {"items":[1,2,]}. Valid: {"items":[1,2]}. JSON does not allow a trailing comma after the final item of an array or the last property of an object. A permissive code editor may accept it as JavaScript, while a JSON API will not.

4–5: unsupported values and comments

4. Invalid: {"result":undefined}. Valid alternatives include {"result":null} or omitting the key entirely, depending on the contract. JSON supports null, true, false, numbers, strings, objects and arrays; undefined is not a JSON value.

5. Invalid: {"active":true // enabled}. Valid: {"active":true}. Standard JSON has no comment syntax. If you need comments for a configuration file, choose a format that explicitly permits them or keep documentation outside the JSON payload.

6–7: backslashes and broken brackets

6. Backslashes inside a JSON string must be escaped. A Windows path such as C:\temp\new can accidentally contain escape sequences, including tab and newline. The correct JSON representation of the literal path is {"path":"C:\\temp\\new"}. Use a serializer when possible instead of manually building strings.

7. Arrays and objects must close in the reverse order they open. Invalid: {"items":[1,2}. Valid: {"items":[1,2]}. Indentation often makes a missing ] or } immediately visible. Do not blindly append a bracket without checking what structure you meant to close.

Valid JSON can still be wrong for your API

The payload {"quantity":"12"} is valid JSON, but the quantity is a string. Some APIs require the number 12 instead. Similarly, the string "0012" may be an important identifier, not an integer you should coerce. Syntax validation will not choose the correct meaning for you.

Minification removes irrelevant whitespace; it does not fix an invalid schema or remove private data. For sensitive customer or production information, use a trusted local workflow. RezSat's JSON Formatter & Validator performs parsing in your browser and does not intentionally send the content to the site's backend.

Useful links and sources

These links point to the original tool or official documentation. Features and free-tier limits may change.