JSON Guide

JSON Guide for formatting, validation, querying, and conversion.

JSON is the everyday data format behind APIs, configuration, logs, web apps, and test fixtures. This guide explains the practical checks developers make before copying JSON into code or sending it downstream.

Which JSON tool should I use?

Start with the job you need to finish. These tools handle common JSON cleanup, validation, inspection, and conversion tasks locally in your browser.

What is JSON?

JSON, short for JavaScript Object Notation, is a text format for structured data. It represents objects, arrays, strings, numbers, booleans, and null values in a syntax that is easy for machines to parse and reasonably easy for people to read.

Developers use JSON for API requests and responses, configuration files, event payloads, exported records, test data, and logs. A JSON document is useful only when it is syntactically valid and the structure matches what the consuming system expects.

JSON syntax basics

  • Objects use curly braces and key-value pairs, such as { "name": "DevCoreTools" }.
  • Arrays use square brackets and preserve item order.
  • Object keys and strings must use double quotes.
  • Trailing commas are not valid JSON.
  • Comments are not part of JSON, even though some configuration formats allow them.
  • Numbers are not quoted unless the consuming system expects strings.

Valid JSON

{ "name": "DevCoreTools", "active": true, "count": 3 }

Invalid JSON

{ name: 'DevCoreTools', active: true, }

The invalid example looks like JavaScript, but JSON requires double-quoted keys and strings, and it does not allow trailing commas.

Formatting JSON

Formatting makes JSON easier to scan by adding indentation and line breaks. It should not change the underlying value. Use the JSON Formatter when you need to inspect nested data, copy a readable version, or review an API payload before debugging.

Validating JSON

Validation answers a narrower question: can this text be parsed as JSON? The JSON Validator catches syntax errors such as missing quotes, bad escape sequences, unexpected commas, and unclosed arrays or objects.

Minifying JSON

Minification removes unnecessary whitespace to make payloads smaller for transport or storage. Use the JSON Minifier when the data is already valid and you need compact output for APIs, fixtures, or generated files.

Comparing JSON

When two payloads look similar, a line diff can miss structural changes. The JSON Diff compares parsed values so you can inspect added, removed, changed, and type-changed paths.

JSONPath basics

JSONPath is a query syntax for selecting values from JSON. Expressions usually begin at $, then navigate through properties, arrays, wildcards, filters, and recursive descent. Try the JSONPath Tester when you need to confirm an expression before placing it in automation or monitoring rules.

JSONPath example

Sample JSON
{ "users": [{ "name": "Asha", "email": "asha@example.com" }] }
Expression
$.users[0].email
Expected result
asha@example.com

JSON Schema basics

JSON Schema describes the expected shape of JSON data: types, required properties, allowed values, array rules, object structure, and constraints. The JSON Schema Validator checks valid JSON against those rules and reports where the data fails.

Schema

{
  "type": "object",
  "required": ["name", "age"],
  "properties": {
    "name": { "type": "string" },
    "age": { "type": "number" }
  }
}

Matching JSON

{ "name": "Asha", "age": 31 }

Common JSON mistakes

Syntax mistakes

  • Using single quotes around strings or object keys.
  • Leaving trailing commas after the last object property or array item.
  • Pasting JavaScript object literals instead of JSON.

Data-shape mistakes

  • Mixing up JSON syntax validation with schema validation.
  • Assuming every nested object or array can flatten cleanly to CSV.

Workflow mistakes

  • Comparing large JSON payloads as plain text instead of parsed structures.
  • Minifying JSON before checking that the data is valid.

JSON Guide FAQ

What is the difference between JSON formatting and JSON validation?

Formatting changes whitespace to make JSON easier to read. Validation checks whether the text can be parsed as JSON.

What is the difference between JSON validation and JSON Schema validation?

JSON validation checks syntax. JSON Schema validation checks valid JSON against required fields, types, and other data-shape rules.

When should I use JSONPath?

Use JSONPath when you need to select a nested value, array item, or group of values from a larger JSON document.

Is JSON minification safe?

Yes, when the input is valid JSON. Minification removes whitespace outside strings and should not change the parsed value.

Why does valid JavaScript object syntax sometimes fail as JSON?

JSON is stricter than JavaScript object literals: keys and strings need double quotes, comments are not allowed, and trailing commas fail.