100% In-Browser & Private

JSON Syntax Standards, Common Errors, and Troubleshooting Guide

JavaScript Object Notation (JSON) is the universal lingua franca of modern web APIs, microservices, database storage (PostgreSQL JSONB, MongoDB BSON), and configuration files. Defined formally by RFC 8259 and ECMA-404, JSON is a language-agnostic, text-based data interchange format designed to be easily readable by humans and easily parsed by machines.

Format & Validate JSON in Real Time

Use our client-side JSON Formatter & Validator to format messy payloads, pinpoint exact syntax errors, and convert data trees without remote API calls.

Open JSON Formatter & Validator →

1. The 6 Permitted JSON Data Types

A JSON document must contain exactly one root value (traditionally an Object or an Array) composed strictly of these six primitive types:

Data Type Syntax Example Standard Specification Rules
String "Hello World" Must be wrapped in double quotes. Unicode compliant.
Number 42, -3.14, 1.0e+5 Double-precision floating point. No leading zeros, no hex/octal.
Boolean true, false Strict lowercase only.
Null null Strict lowercase representation of an empty value.
Object {"key": "value"} Unordered collection of key/value pairs. Keys MUST be strings.
Array [1, "two", false] Ordered zero-indexed sequence of values separated by commas.

2. What JSON Cannot Store (Common Invalid Types)

Because JSON is a serialization standard rather than an executable runtime language, the following JavaScript constructs are strictly forbidden in JSON:

  • Functions & Methods: Cannot be serialized.
  • undefined: Property keys with undefined values are omitted or produce syntax errors.
  • Special Number Values: NaN, Infinity, and -Infinity are illegal in JSON. They must be encoded as null.
  • Dates: JSON has no native Date type. Dates must be serialized as ISO 8601 strings (e.g. "2026-10-28T14:00:00Z").
  • Comments: Comments (like // or /* */) are intentionally omitted from RFC 8259.

3. Top 7 Most Common JSON Syntax Errors

► Trap #1: Trailing Commas

✗ BAD: [ “apple”, “banana”, “cherry”, ]

✓ GOOD: [ “apple”, “banana”, “cherry” ]

Trailing commas after the final element in an array or object are the #1 cause of parse errors in web APIs.

► Trap #2: Single Quotes Instead of Double Quotes

✗ BAD: { ‘userId’: 101, ‘status’: ‘active’ }

✓ GOOD: { “userId”: 101, “status”: “active” }

JSON strictly forbids single quotes. Both property names and string values must use standard ASCII double quotes.

► Trap #3: Unquoted Property Keys

✗ BAD: { username: “alex99”, email: “[email protected]” }

✓ GOOD: { “username”: “alex99”, “email”: “[email protected]” }

While JavaScript object literals permit bare identifiers, standard JSON parsers reject unquoted keys.

4. String Quoting & Character Escaping Rules

Certain characters inside JSON strings must be escaped using a preceding backslash:

  • Double quote: "
  • Backslash:
  • Newline:
  • Carriage return:
  • Tab:
  • Unicode code points: uXXXX

5. Safe Parsing Practices in Modern Programming Languages

Always wrap JSON parsing in exception handling blocks to prevent application crashes on corrupted payloads:

// JavaScript / TypeScript:
try {
const data = JSON.parse(rawString);
} catch (err) {
console.error(“Malformed JSON received:”, err.message);
}

6. Frequently Asked Questions

What is the MIME content type for JSON?

The official registered IANA media type for JSON is application/json with charset UTF-8.