What is JSON? A Complete Guide for Developers

BY TOOLS.FUN  ·  MARCH 28, 2026  ·  6 min read

JSON — JavaScript Object Notation — is the lingua franca of data exchange on the modern web. It powers REST APIs, configuration files, NoSQL databases, and inter-service communication in virtually every tech stack. Despite its name, JSON is language-agnostic: parsers exist for Python, Ruby, Go, Java, C#, PHP, and dozens of other languages. Understanding JSON thoroughly makes you a more effective developer across every discipline.

JSON Syntax

JSON is built on two data structures: an ordered list (array) and a collection of name/value pairs (object). The entire specification fits on a single page, which is a big part of its appeal over earlier formats like XML.

A JSON document is a single value — either an object, an array, a string, a number, a boolean, or null. Objects are wrapped in curly braces {} and contain comma-separated key/value pairs where keys are always double-quoted strings. Arrays are wrapped in square brackets [] and contain comma-separated values.

{
  "name": "Alice",
  "age": 30,
  "active": true,
  "scores": [98, 87, 92],
  "address": {
    "city": "London",
    "zip": "EC1A 1BB"
  },
  "nickname": null
}
Key point: JSON keys must always be double-quoted strings. Single quotes are not valid JSON, even though JavaScript allows them in object literals.

JSON Data Types

JSON supports exactly six data types, and knowing their rules prevents countless bugs:

Key point: JSON has no Date type. Dates are typically serialised as ISO 8601 strings ("2026-03-28T12:00:00Z") or as Unix timestamps (integers).

Valid vs Invalid JSON Examples

Because JSON has strict syntax rules, small mistakes cause parse errors. Here are the most common traps:

// INVALID — trailing comma
{ "a": 1, "b": 2, }

// INVALID — single-quoted string
{ 'name': 'Alice' }

// INVALID — unquoted key
{ name: "Alice" }

// INVALID — comment (JSON has no comment syntax)
{ "port": 8080 // default port }

// VALID
{ "a": 1, "b": 2 }
Key point: JSON does not support comments. If you need a config format with comments, consider JSONC (used by VS Code) or YAML.

JSON in REST APIs

REST APIs overwhelmingly use JSON as their request and response body format. When a client sends a POST request, it sets the Content-Type: application/json header and sends a JSON body. The server responds with Content-Type: application/json and a JSON payload.

// Request body
POST /api/users
Content-Type: application/json

{ "username": "alice", "email": "[email protected]" }

// Response body
HTTP/1.1 201 Created
Content-Type: application/json

{ "id": 42, "username": "alice", "created_at": "2026-03-28T09:00:00Z" }

Most HTTP client libraries handle JSON serialisation and deserialisation automatically. In JavaScript, JSON.stringify() serialises objects and JSON.parse() deserialises strings. In Python, the json module provides json.dumps() and json.loads().

JSON in Configuration Files

Many tools use JSON for their configuration: package.json in Node.js, tsconfig.json in TypeScript, manifest.json in Chrome extensions, and appsettings.json in .NET. Its strict syntax and universal parser support make it a reliable choice for machine-written config, though the lack of comments is a persistent complaint (leading many teams to choose YAML instead for human-authored config).

Common JSON Mistakes

Beyond syntax errors, there are semantic mistakes that bite developers repeatedly:

Key point: Always validate JSON from external sources before parsing. A malformed payload from a third-party API can crash your application if you don't handle parse errors.

Tools for Working with JSON

The JSON Formatter & Validator at Tools.Fun lets you paste any JSON string and instantly validates it, highlights syntax errors, and pretty-prints the result with collapsible tree navigation. It's the fastest way to debug malformed API responses or inspect deeply nested payloads — no install, no login, runs entirely in your browser.

For schema validation, JSON Schema lets you define the expected shape of a JSON document and validate instances against it. Tools like Ajv (JavaScript) and jsonschema (Python) implement the spec and are widely used in API testing pipelines.

Tools for working with JSON: format and validate JSON with our JSON Formatter, convert to other formats with JSON to YAML and JSON to XML, compare two JSON documents with our Diff Tool, and test JSON path patterns with our RegExp Tester. Decode Base64-encoded JSON from APIs with our Base64 Decoder.
← Back