The Complete JSON Guide

Free Format · Validate · Convert · Best Practices No signup · No data stored · Works offline

Tools in this guide

JSON Formatter & Validator
Format, validate, minify and fix JSON
JSON to YAML Converter
Convert JSON to Kubernetes-ready YAML
JSON to CSV Converter
Export JSON arrays as spreadsheets
JSON to XML Converter
Convert JSON to well-formed XML
JSON to TOML Converter
Convert JSON to Rust/Python configs
JSON to TOON Converter
Token-efficient format for LLMs
YAML Formatter
Format and validate YAML config files
Base64 Encoder
Encode binary data for JSON payloads
Last updated: March 2026  ·  v1.0
Quick Answer
What is JSON formatting and why does it matter?

JSON formatting rewrites raw, minified JSON with consistent indentation to make it human-readable and debuggable. The 5 most important things to know:

  1. Use 2-space indent for web projects (Node.js/JS default), 4-space for Python/Java.
  2. All keys and string values must use double quotes — single quotes are invalid JSON.
  3. Trailing commas always cause parse errors, even after the last array/object element.
  4. JSON has no comment syntax — // and /* */ both break parsing.
  5. Dates have no native type — always use ISO 8601 strings: 2024-01-15T10:30:00Z.

JSON (JavaScript Object Notation) is the universal language of web APIs, configuration files, and data exchange. Whether you are debugging an API response, migrating data between systems, or configuring a cloud service, you need reliable JSON tooling in your browser — no install, no signup, no data leaving your machine.

What is JSON formatting and why does it matter?

JSON is a lightweight text format derived from JavaScript object syntax. It uses key-value pairs and ordered lists to represent structured data, and every major programming language can parse and generate it natively.

Raw JSON from an API often arrives minified — a single line with no whitespace. While this saves bandwidth, it is unreadable to humans. A JSON formatter reindents it with consistent spacing, making nested structures instantly visible. Proper formatting is not cosmetic: it directly affects your ability to spot missing brackets, misplaced commas, and type mismatches that cause runtime errors.

Which JSON indentation style should you use?

The JSON specification (RFC 8259) imposes no indentation rules. In practice, three conventions dominate.

2-space indentation is favoured by JavaScript and Node.js communities. It balances readability with compactness, keeping deeply nested structures on screen without horizontal scrolling. Most linters and editors default to 2 spaces for JSON.

4-space indentation is common in Python and Java projects. It makes each nesting level more visually distinct, which helps when reading deeply nested API responses.

Tab indentation allows each developer to choose their display width in their editor. It is common in C and Go projects. Our JSON Formatter supports all three. For most web API work, 2-space is the right default.

What are the most common JSON validation errors?

JSON is strict — a single character out of place breaks the entire document. Here are the five most common errors:

Trailing commas — JSON forbids a comma after the last item in an object or array. {"a":1, "b":2,} is invalid. Use the Fix Quotes button to catch this automatically.

Single quotes — JSON requires double quotes for all strings and keys. {'key': 'value'} is invalid JSON. Use the Fix Quotes button to convert automatically.

Unquoted keys — JavaScript objects allow bare keys, but JSON does not. Every key must be a double-quoted string.

Comments — JSON has no comment syntax. Both // and /* */ comments cause parse errors. Strip them before validating.

NaN and Infinity — Valid in JavaScript but not in JSON. Replace with null or a sentinel number like -1.

How do you convert JSON to YAML, CSV, XML or TOML?

Different systems need data in different shapes. Here is when to use each converter:

JSON → YAML — YAML is the standard for Kubernetes manifests, Docker Compose files, GitHub Actions workflows, and most CI/CD pipelines. Convert when moving configuration from a JSON-based tool to a YAML-based one.

JSON → CSV — Spreadsheet tools and data pipelines expect CSV. Convert a JSON array of objects to a CSV where each object becomes a row and each key becomes a column header.

JSON → XML — Legacy enterprise systems, SOAP APIs, and many Java frameworks use XML. Convert JSON payloads to well-formed XML for integration with these systems.

JSON → TOML — Rust's Cargo, Python's pyproject.toml, and Hugo's config files use TOML. TOML is more explicit than YAML and better suited for human-edited configuration files.

All conversions run entirely in your browser. No data is sent to any server.

What are the best practices for JSON in APIs?

Use snake_case for keys consistently across your API. Mixing userId and user_id in the same codebase creates unnecessary mapping code.

Avoid deeply nested structures. If your JSON is 6+ levels deep, it is a sign the data model needs refactoring. Flat structures are easier to serialize, deserialize, and cache.

Represent missing data as null, not absent. {"email": null} communicates intent better than omitting the key entirely.

Use ISO 8601 for dates. JSON has no native date type. Always use strings in ISO 8601 format (2024-01-15T10:30:00Z) rather than Unix timestamps or locale-specific formats.

Validate at the boundary. Parse and validate incoming JSON at the edge of your system before it flows into your business logic. JSON Schema is the standard tool for this.

Frequently asked questions about JSON

What is the difference between JSON and JSON5?

JSON5 is an extension that adds comments, trailing commas, unquoted keys, and single-quoted strings to JSON. Most APIs and parsers expect strict JSON (RFC 8259), not JSON5.

Can JSON contain binary data?

Not directly. The standard approach is to Base64-encode binary data and store it as a JSON string. Our Base64 Encoder handles this conversion.

What is the maximum size of a JSON file?

The JSON specification has no size limit. Practical limits are imposed by your parser's memory. Our formatter processes large files efficiently in-browser.

Is JSON the same as a JavaScript object?

No. A JavaScript object is a runtime data structure. JSON is a text serialization format. Functions, undefined, and symbols are not valid JSON values.

How do I minify JSON for production?

Use our JSON Formatter's Minify button. Minification removes all whitespace, reducing file size by 20–60% for typical API payloads.