📖 JSON Formatting Guide

Master the syntax specifications of JSON, write clean data structures, and resolve parse errors quickly.

← Dashboard

What is JSON?

**JSON (JavaScript Object Notation)** is a lightweight data-interchange format. It is easy for humans to read and write, and extremely easy for machines to parse and generate. Originally derived from JavaScript, it has become language-independent and is the standard format for API data transfer on the web.

The Strict Rules of JSON Syntax

While JavaScript object literals are very permissive, JSON has a strict standard (RFC 8259). Mismatches will cause parsers to fail. Here are the key rules:

  • Keys must be double-quoted: { "key": "value" } is valid, but { key: "value" } is not.
  • No trailing commas: In JavaScript, [1, 2, 3,] is allowed. In JSON, a trailing comma before a closing bracket or brace is a syntax error.
  • Double quotes for strings: String values must be wrapped in double quotes. Single quotes will trigger an error.
  • Numeric values: Numbers must be in standard decimal representation. Leading zeros (e.g. 05) are forbidden.

Formatting Best Practices

For human readability, standard JSON formatting uses **2 spaces** or **4 spaces** indentation. For production deployments and API responses, **Minification** should be used. Minified JSON strips out carriage returns, line breaks, and space margins to save up to 20% in network transit bandwidth.

Frequently Asked Questions

Detailed structural validation guide FAQs.