Guide
Data
JSON
Developer Reference

JSON Data Processing Workflows

JSON processing follows a predictable sequence: validate syntax, format for inspection, flatten nested structure for tabular destinations, diff against expected payloads, then convert or load. This guide covers each step with practical patterns for API responses, webhook payloads, config comparisons, and data pipeline preparation.

For a broader overview of data formats including CSV, XML, and Excel, see the Data Formatting & Processing Basics guide.

1. Validate JSON First

Before transforming JSON, validate it. Syntax errors cause silent failures downstream — a conversion tool may output corrupt data, or a database insert may silently drop fields. Validate early so you get a meaningful error at the source rather than a mystery failure later.

Use the JSON Formatter to parse and validate — it reports the exact line and column of any error.

The most common JSON syntax errors:

Trailing comma{"key": "value",}

Remove the comma after the last key-value pair. JSON does not permit trailing commas (unlike JavaScript).

Single-quoted strings{"key": 'value'}

JSON requires double quotes. Replace single quotes with double quotes.

Unquoted keys{key: "value"}

JSON object keys must be double-quoted strings. {key: ...} is JavaScript object literal syntax, not JSON.

Comments{"key": "value" // comment}

JSON does not support comments. Remove them, or switch to JSONC or YAML if you need inline documentation.

Unescaped control characters{"note": "line1\nline2"}

Newlines, tabs, and other control characters inside strings must be escaped (\n, \t, etc.).

2. Format and Inspect

Minified JSON is unreadable. API responses from production systems, webhook payloads captured in logs, and JSON from curl are often compact single lines. Formatting adds consistent indentation and makes the structure immediately visible.

The JSON Formatter pretty-prints with configurable indentation (2 or 4 spaces) and also minifies when you need to reduce payload size. Use it when:

  • Reading an API response from Postman, Insomnia, or curl
  • Inspecting a webhook payload before writing a handler
  • Reviewing a config file that was machine-generated
  • Preparing JSON to paste into a code review comment or documentation

Tip: Minify before network transmission

Minified JSON is 20–40% smaller than pretty-printed for typical payloads (mostly by removing whitespace). For high-frequency API calls, minifying the payload reduces bandwidth and latency. Never store human-edited config files minified — readability matters more than size for files you maintain.

3. Flatten for Tabular Destinations

JSON's nested structure is incompatible with CSV, spreadsheets, and most relational database tables. Flattening converts nested keys to dot-notation or underscore-notation at a single level:

Before — nested

{
  "user": {
    "name": "Alice",
    "address": {
      "city": "London"
    }
  }
}

After — flattened

{
  "user_name": "Alice",
  "user_address_city": "London"
}

After flattening, the JSON maps directly to one CSV row per object. Use the JSON Flattener tool to perform this transformation, then pass the result to JSON to CSV.

What to watch for when flattening:

Arrays within objects

An array of tags or line items has no direct flat equivalent. Options: join as a string ("tag1|tag2"), one-hot-encode (one boolean column per tag), or explode (one row per array element, repeating parent fields).

Key name conflicts

After flattening, two different paths may produce the same key name (e.g., "a.b_c" and "a_b.c" both become "a_b_c"). Choose a separator that does not appear in your key names.

Null vs absent fields

A null field and an absent field are different in JSON. Both become an empty cell in CSV, losing the distinction. If this matters for your use case, normalize nulls before flattening.

Deeply nested structures

Flattening a 5-level-deep JSON object produces very long column names. Consider whether the full path is meaningful, or whether you should extract a specific subtree first.

4. Diff Two JSON Payloads

Comparing two JSON documents is one of the most common debugging tasks. Manually scanning for differences in large JSON payloads is error-prone. The JSON Diff tool highlights added, removed, and modified keys — including changes deep within nested objects and arrays.

API versioning
Paste the response from /v1/users/1 and /v2/users/1 to see exactly which fields were renamed, added, or removed between API versions.
Webhook debugging
Compare a successful webhook payload against a failing one to identify which fields differ. Often the issue is a missing field, a type change (string vs number), or an unexpected null.
Config change review
Diff the production config against the staging config before a deployment. Catch unexpected differences in feature flags, timeouts, or connection strings.
Test fixture validation
Compare actual API response against expected fixture to detect regressions. More reliable than string equality because field order does not matter in JSON.
Schema evolution
Diff a newly generated JSON Schema against the previous version to review backwards-compatibility implications before releasing.
Data pipeline output
Compare the output of a transformation pipeline before and after a code change to verify behaviour is unchanged — or that the expected change was applied correctly.

5. Convert to CSV, XML, or Other Formats

JSON often needs to cross format boundaries — into spreadsheets, legacy systems, databases, or other APIs. Here are the most common conversion scenarios:

ConversionWhen to useKey considerationTool
JSON → CSVExcel exports, DB bulk load, ML datasetsFlatten nested structure firstJSON to CSV →
CSV → JSONLoading CSV data into an API or document storeDecide whether to infer types or keep stringsCSV to JSON →
JSON → XMLSOAP integrations, legacy enterprise systemsXML attributes have no JSON equivalentJSON to XML →
XML → JSONConsuming XML API responses in a modern stackArrays of 1 vs N elements behave differentlyXML to JSON →

6. Common Workflow Patterns

API Response → CSV Export
  1. 1Capture JSON response from API (curl, Postman, fetch)
  2. 2Validate and inspect with JSON Formatter
  3. 3Flatten nested structure with JSON Flattener
  4. 4Convert to CSV with JSON to CSV
  5. 5Open in Excel or Google Sheets, or load into database

This is the most common JSON workflow for data analysts who need to explore API data in a spreadsheet.

Webhook Payload Inspection
  1. 1Log raw webhook POST body to a file or console
  2. 2Paste into JSON Formatter to validate and pretty-print
  3. 3Compare successful vs failed payloads with JSON Diff
  4. 4Identify which fields differ and update your handler

JSON Diff is essential here — failed and successful webhooks often look identical to the naked eye but differ in a single field type or value.

Config Version Comparison
  1. 1Export current config as JSON (or read from file)
  2. 2Export proposed new config as JSON
  3. 3Diff with JSON Diff to review all changes
  4. 4Confirm only intended changes are present
  5. 5Deploy with confidence

JSON Diff compares semantically — field order differences are ignored, so you see actual data changes, not whitespace noise.

Preparing Data for a Relational Database
  1. 1Fetch or export JSON data from source
  2. 2Validate structure with JSON Formatter
  3. 3Flatten nested objects with JSON Flattener
  4. 4Convert to CSV with JSON to CSV
  5. 5Review column names and data types
  6. 6Run CSV to SQL Insert to generate INSERT statements (for smaller datasets)

For large datasets, load the CSV directly using the database's bulk import mechanism (PostgreSQL COPY, MySQL LOAD DATA) rather than generating INSERT statements.

7. Common Mistakes

Not validating before converting

Converting invalid JSON produces garbage output silently. The converter may not raise an error — it may just truncate at the first syntax error or produce an empty result. Always validate first.

Ignoring large integer precision loss

JavaScript's JSON.parse() silently loses precision for integers above 2^53 (9,007,199,254,740,992). Database auto-increment IDs, snowflake IDs, and Unix timestamps in milliseconds can exceed this. Use strings for large integer IDs in JSON.

Treating JSON.parse() as safe for untrusted input

JSON.parse() can throw on invalid input. Always wrap it in try/catch (or use a safe parsing wrapper) when processing external data. An unhandled parse error can crash a Node.js server or fail a batch job silently.

Flattening without checking for array fields

Running a flattener on JSON that contains arrays of objects does not produce what you expect. Arrays are typically serialised as JSON strings per cell, not exploded. Inspect the output and handle arrays explicitly.

Using JSON for large streaming datasets

A standard JSON array of 10 million objects must be fully parsed before any record is accessible. For large streaming datasets, use JSON Lines (NDJSON) — one JSON object per line — which allows line-by-line processing without loading the entire file into memory.

Assuming JSON diff is the same as text diff

A text diff reports field order differences as changes. In JSON, {"a":1,"b":2} and {"b":2,"a":1} are semantically identical. Use a semantic JSON diff (like the JSON Diff tool) which treats JSON as a tree, not a string.

Try the Tools

All tools run entirely in your browser. No data is uploaded. Browse all data tools →

Frequently Asked Questions

Related Reading