Developer Tool

JSON Formatter & Validator

Format, validate, minify, repair and diff JSON instantly. Syntax highlighting, stats panel, file upload and download.

Input JSON
Formatted Output

    
Input size
Output size
Keys
Arrays
Strings
Numbers
Depth
Nulls

JSON Diff — Compare Two JSON Objects

Paste two JSON strings to highlight line-by-line differences. Both inputs are auto-formatted before comparison.

JSON A
JSON B
Diff Output

Key & Path Search

Search for key names or paths in your formatted JSON. Results show the full dot/bracket path to each match.

No matching paths found.

How to Use the JSON Formatter

Six ways to work with JSON on this tool — each designed to save you time in real development workflows.

1
Paste & Format
Paste any JSON into the left panel. Click Format or just type — the output updates live with syntax highlighting and proper indentation.
2
Validate & Debug
Invalid JSON shows a red error banner with the exact parser message and position. Fix the error and the output clears the moment syntax is corrected.
3
Minify for Production
Click Minify to strip all whitespace. Use this before embedding JSON in API responses, config files, or JavaScript bundles.
4
Auto-Repair Common Errors
Auto-Repair fixes trailing commas, single-quoted strings, and unquoted keys — the three most common JSON mistakes from copy-pasted data.
5
Compare Two JSONs
Use the JSON Diff section to paste two objects and instantly see which lines were added, removed, or changed.
6
Upload or Download
Upload a .json file from disk, or download the formatted output as a properly named formatted.json file.

All Features at a Glance

Everything packed into this free tool — no account, no limits, no ads in the output.

🎨
Syntax Highlighting
Keys, strings, numbers, booleans, and null values each render in a distinct colour for instant visual scanning.
Instant Validation
Real-time validation as you type. Exact error messages from the native JS parser — including character position.
🗜️
Minifier
Remove all whitespace to produce the smallest valid JSON string. Ideal for APIs and embedded configs.
🔧
Auto-Repair
Automatically fixes trailing commas, single quotes, and unquoted keys — common mistakes in hand-written JSON.
🔀
JSON Diff
Side-by-side comparison of two JSON objects with colour-coded added, removed, and unchanged lines.
🔍
Path Search
Search for keys or paths inside deeply nested JSON. Returns all matching dot-notation and bracket paths.
📊
Stats Panel
Counts of keys, arrays, strings, numbers, nulls, and nesting depth — useful for auditing large JSON payloads.
🔢
Sort Keys
Alphabetically sort all object keys at every level. Useful for diffing, deduplication, and consistent config files.

JSON Syntax Cheatsheet

Quick reference for valid JSON — the rules developers most often get wrong.

Object
"key": "value" "num": 42 "flag": true "empty": null
Array
["alpha", "beta"] [1, 2, 3.14] [true, false, null] [{}, {}, {}]
Valid ✓ vs Invalid ✗
Keys must be double-quoted {key: "val"} — unquoted key {'key': 'val'} — single quotes {a:1,} — trailing comma // comments — not allowed
String Escapes
"\"" double quote "\\" backslash "\n" newline "\t" tab "A" Unicode (A)
Number Formats
42 integer -7 negative 3.14 decimal 1.2e10 scientific 0xff hex not valid NaN not valid
Whitespace Rules
Spaces, tabs, newlines are allowed between tokens. NOT inside string values (use \n, \t escapes there). Minified = no whitespace.

Frequently Asked Questions

Common questions about JSON formatting, validation, and this tool.

Formatting (beautifying) adds indentation and line breaks to make JSON human-readable. Minifying removes all whitespace to produce the smallest possible string for machine processing. Both represent the same data — only the encoding differs. Use formatted JSON during development and debugging; use minified JSON in production APIs and config files to reduce payload size.

The most common causes are: (1) trailing commas after the last element in an object or array ({"a":1,}), (2) single-quoted strings instead of double quotes ({'key':'val'}), (3) unquoted keys ({key: "val"}), (4) JavaScript comments (// or /* */), (5) undefined, NaN, or Infinity values which are not valid JSON. Use the Auto-Repair button to fix the first three automatically.

Auto-Repair handles the three most common hand-written JSON mistakes: trailing commas ([1,2,][1,2]), single-quoted strings ('hello'"hello"), and unquoted object keys ({name:"val"}{"name":"val"}). It cannot repair structural errors like mismatched brackets or completely malformed data.

No. All processing happens entirely in your browser using JavaScript. Your JSON data never leaves your device and is never stored or transmitted to any server. This makes the tool safe to use with confidential API responses, configuration data, or private payloads.

JSON (JavaScript Object Notation) is a strict text-based data format derived from JavaScript object syntax, but with important differences: all keys must be double-quoted strings, values can only be strings, numbers, booleans, null, arrays, or objects — not functions or undefined. JavaScript objects are runtime data structures that allow unquoted keys, functions, and special values. JSON is a serialisation format; JavaScript objects are in-memory data.

This browser-based tool handles JSON up to several MB comfortably. For files larger than ~10 MB, browser performance may degrade. For large files: use the file upload button instead of pasting to avoid clipboard limits, use minify mode to reduce output size, or consider command-line tools like jq for gigabyte-scale files.

Sort Keys alphabetically reorders all object keys at every nesting level. This is useful for: comparing two JSON objects that have the same data in different key order, producing deterministic output for version control, and deduplication workflows where key order varies between sources. Array element order is not changed.

Yes — use the JSON Diff section on this page. Paste the first JSON in the "JSON A" box and the second in "JSON B". Both are automatically formatted before comparison so whitespace differences are ignored. Lines shown in green were added in B; lines in red were removed from A; unmarked lines are unchanged.

JSON paths describe the location of a value inside a JSON structure using dot notation for object keys (.name, .meta.version) and bracket notation for array indices ([0], [2]) and keys with special characters (["my-key"]). The path search in this tool shows the full path to every key matching your query, starting from the root $.

Two spaces is the most common convention for JSON (used by npm, package.json, and most style guides). Four spaces is popular in Python-oriented projects. Tabs produce the smallest formatted size since they are one character but visually expand. For files committed to version control, match your project's existing convention to avoid noisy diffs.

Related Tools

View all →

Related Articles

View all →