Structural JSON diffing vs line-based text comparison
Standard text diff tools (such as Git diff or GNU diff) compare text line by line. When two JSON payloads are formatted differently, minified on a single line, or have reordered keys, a text-based diff produces dozens of false differences that obscure real data changes. A single reformatted object or indentation change can flag an entire payload as modified even when the underlying data is identical.
This JSON Diff Viewer performs AST-based structural comparison. It parses both JSON strings into syntax trees, validates RFC 8259 compliance, and compares values by property path. It identifies added properties, removed fields, modified values, and data type changes regardless of whitespace, line breaks, or key formatting. This allows software engineers, API developers, and QA teams to isolate actual payload differences between API versions, database records, and configuration files immediately.
Understanding difference categories and path notation
Differences are grouped into four distinct categories to give you actionable clarity:
- Added: A key or array index exists in the modified JSON (B) that was absent from the original JSON (A).
- Removed: A key or array index exists in the original JSON (A) but was removed from the modified JSON (B).
- Changed value: The property exists on both sides with identical data types, but the underlying scalar value has changed (for example, false changing to true, or a timeout value updating from 5000 to 10000).
- Changed type: The property exists on both sides but its data type was altered (for example, a port number changed from a number 8080 to a string "8080", or an object transformed into an array).
Every difference is located with standard property path notation. Top-level properties appear with direct dot notation (such as settings.timeout). Array items include their zero-based bracketed index (such as endpoints[1].path). When property names contain spaces, dots, slashes, or Unicode symbols, the tool uses quoted bracket syntax (such as ["user.id"] or ["café"]), ensuring unambiguous tracking across deeply nested structures.
Array ordering and key order options
JSON specifications (RFC 8259) define an object as an unordered collection of zero or more name-value pairs. By default, our diff engine enables Ignore key order in objects, meaning {"a": 1, "b": 2} and {"b": 2, "a": 1} are treated as identical. If your application or serialization protocol requires strict property ordering, unchecking this option immediately flags key order discrepancies.
For arrays, JSON specifies that order is significant. By default, array items are compared index-by-index ([0] against [0], [1] against [1]). In many distributed systems, tag collections, or database query results, arrays represent unordered sets where sequence does not matter. Checking Ignore array element order treats arrays as multisets, matching identical items regardless of their array index and isolating only truly added or missing elements.
Preserving 64-bit integer IDs and large numbers
In standard JavaScript environments, native JSON.parse converts numbers into IEEE 754 64-bit floating-point values. This format provides 53 bits of integer precision, capping exact representation at Number.MAX_SAFE_INTEGER (9007199254740991). When diffing enterprise API responses containing 64-bit database keys, Twitter/Discord snowflake identifiers, or high-precision financial decimals, native parsing silently truncates trailing digits, causing different numbers to appear identical or identical numbers to mutate.
Our diff engine incorporates an integrated number tokenizer that preserves the raw textual representation of every number literal. Large integer identifiers (such as 1234567890123456789 vs 1234567890123456788) are compared using exact BigInt semantics, ensuring that snowflake IDs and arbitrary-precision values are never falsely reported as matching.
Worked example: comparing API response versions
The default loaded example demonstrates differences across all four categories between two versions of an API configuration:
| Path | Change type | Original (A) | Modified (B) | Explanation |
|---|---|---|---|---|
| version | Changed value | 1.2 | 2.0 | Minor version upgraded to major version |
| settings.timeout | Changed type | 5000 (number) | "10000" (string) | Number converted to string representation |
| settings.retries | Changed value | 3 | 5 | Retry limit increased |
| settings.debug | Removed | false | (undefined) | Debug toggle removed from configuration |
| settings.region | Added | (undefined) | "us-east" | Cloud deployment region introduced |
| tags[3] | Added | (undefined) | "cloud" | Fourth tag appended to the tags array |
| endpoints[1].path | Changed value | "/api/v1/users" | "/api/v2/users" | User endpoint routed to v2 endpoint |
| legacySupport | Removed | true | (undefined) | Deprecated legacy flag removed |
| notes | Added | (undefined) | "Upgraded to v2 architecture" | Deployment release note added |
The summary reports 9 differences: 3 added, 2 removed, 3 changed values, and 1 changed type. You can click any filter button to isolate specific change types or copy the full diff report to your clipboard.
Client-side validation and security
Validating syntax before comparing saves debugging time. When an invalid JSON string is pasted, our parser flags the exact line number, column offset, and token snippet, pinpointing missing commas, single quotes, or trailing commas immediately. All processing runs locally in your web browser. No JSON payloads, configuration secrets, or customer tokens are ever transmitted across a network, ensuring complete data confidentiality.