JSON Diff / Compare Two JSON Files
Semantic JSON comparison tool for developers. Visualize differences between two JSON objects, validate syntax, and debug API responses or configuration files with precision.
About
Data serialization formats form the backbone of modern web infrastructure. When configuration files or API payloads diverge, identifying the exact location of the discrepancy manually is inefficient and prone to human error. This utility performs a semantic comparison between two JSON datasets. Unlike textual diff tools that flag whitespace or indentation changes as conflicts, this logic parses the underlying object structure. It isolates actual data modifications, type changes, or structural mutations that impact application logic.
Accuracy in data validation mitigates critical failures in deployment pipelines. A missing key in a package.json manifest or a type mismatch in a REST API response can crash services. This tool highlights additions in green and deletions in red. It supports deep nesting validation. It handles array index shifting and complex object trees. Developers use this for regression testing, analyzing state dumps, or auditing permission policies where strict adherence to schema is mandatory.
Formulas
The comparison logic evaluates the set difference between two keysets, KA and KB. For any key k, the state is determined by:
For nested structures, the algorithm applies recursion diff(A[k], B[k]). Array comparisons typically utilize a Longest Common Subsequence (LCS) approach to minimize noise during shifts.
Reference Data
| JSON Type | JavaScript Primitive | Comparison Logic | Edge Cases & Behavior |
|---|---|---|---|
| Object | Object | Deep recursive key matching | Key order is ignored. Missing keys trigger DELETED status. |
| Array | Array | Index-based or Value-based scan | Order matters. Insertions shift subsequent indices. |
| String | String | Strict equality (===) | Case sensitivity enforced. Encoding differences may flag diffs. |
| Number | Number | Numeric value equality | 10 matches 10.0. Floating point precision handled via epsilon. |
| Boolean | Boolean | Truthiness check | true vs "true" flags a Type Mismatch. |
| Null | null | Strict null check | null is not undefined (undefined keys are usually omitted). |
| Empty Structure | {} or [] | Length/Size check | Empty objects are structurally equal regardless of formatting. |
| Large Integers | BigInt | String parsing (safe mode) | Very large IDs may lose precision if parsed as standard JS numbers. |