DevBlacksmith

Tech blog and developer tools

JSON Payload Generator

What Is JSON?

JSON (JavaScript Object Notation) is a lightweight data interchange format that has become the de facto standard for web APIs. It was popularized by Douglas Crockford in the early 2000s and formalized in RFC 7159. Despite its name suggesting a JavaScript connection, JSON is language-independent and supported by virtually every programming language.

Before JSON, XML was the dominant data format for APIs (remember SOAP?). JSON won because it is significantly more compact, easier to read, and maps naturally to data structures in most programming languages. A typical JSON response is 30-50% smaller than its XML equivalent, which matters when millions of API calls happen per second.

Fun fact: Douglas Crockford did not "invent" JSON. He discovered that a subset of JavaScript object literal syntax already existed as a perfect data format. He simply gave it a name and a specification. Crockford has said that JSON's greatest feature is that it is "not XML". The json.org website, which defines the format, has barely changed since 2002.

API Response Patterns

Most well-designed APIs follow common JSON patterns: wrapping data in a "data" key, providing pagination metadata, using consistent error formats, and including request IDs for debugging. These conventions make APIs predictable and easier to consume.

JSON vs YAML

YAML is a superset of JSON often used for configuration files (Docker Compose, Kubernetes, GitHub Actions). YAML is more human-readable but harder to parse and prone to whitespace errors. JSON is preferred for data exchange; YAML for configuration.

Webhooks

Webhooks are HTTP callbacks that send JSON payloads to your server when events occur. Stripe sends payment events, GitHub sends push notifications, and Slack sends message events. They turn polling ("is there new data?") into push notifications.

JSON5 and JSONC

Standard JSON does not allow comments or trailing commas, which is annoying for config files. JSON5 and JSONC extend JSON with comments, trailing commas, and unquoted keys. VS Code uses JSONC for its settings.json file.