Instantly clean, validate, and inspect web payloads
Compare two JSON payloads side-by-side with semantic object diffing and LCS array alignment. Instantly detect added, removed, and modified keys — 100% client-side, zero data uploaded.
Every tool runs in your browser, so the JSON you paste never leaves your device.
Formatting, minifying, repairing, and the tree view all run on your device, so there are no uploads to wait on.
Syntax errors like unescaped quotes and trailing commas are flagged with their exact line and column.
How PrettyJSON compares two JSON payloads using RFC 8259 compliant key-order-agnostic object comparison and Longest Common Subsequence array alignment.
RFC 8259 §4 explicitly states that JSON objects are unordered collections of name/value pairs — the order in which keys appear carries zero semantic meaning. This means {"a":1,"b":2} and {"b":2,"a":1} are logically identical documents. Naive diff tools that compare keys by insertion order will incorrectly flag these as different, generating false positive noise that wastes developer time. PrettyJSON's semantic diff engine builds key-set unions from both objects and compares values by key name lookup, not positional iteration. Only genuine additions (keys present only in the modified object), removals (keys present only in the original), and value modifications are reported. This approach guarantees that re-serialized API responses, database exports with non-deterministic key ordering, and shuffled configuration files produce zero spurious diff entries.
The most common pitfall in JSON comparison tools is naive index-by-index array diffing. If one element is inserted at the beginning of an array, every subsequent index pair mismatches, flooding the diff with false "modified" entries. PrettyJSON solves this using a Longest Common Subsequence (LCS) dynamic programming algorithm. The LCS algorithm computes the longest ordered subsequence of elements common to both arrays using deep equality matching. By walking the LCS alignment table, the diff engine precisely classifies each element as unchanged (present in both arrays), added (only in modified), or removed (only in original). For example, comparing ["a","b","c","d"] vs ["a","x","b","c","d"] correctly identifies a single insertion of "x" at index 1, instead of flagging 4 cascading false changes. The LCS implementation uses standard O(m×n) dynamic programming, which handles arrays of several hundred elements instantly in-browser.
Original: ["a", "b", "c", "d"]
Modified: ["a", "x", "b", "c", "d"]
--- Naive Index Diff (INCORRECT) ---
[1] Modified: "b" → "x"
[2] Modified: "c" → "b"
[3] Modified: "d" → "c"
[4] Added: "d"
→ 4 changes reported (3 are false positives!)
--- LCS Smart Diff (CORRECT) ---
[1] Added: "x"
→ 1 change reported (accurate!)PrettyJSON's diff engine composes the semantic object diff and LCS array diff algorithms recursively. At each node in the JSON tree, the engine dispatches to the appropriate strategy: object nodes use key-set union comparison, array nodes use LCS alignment, and primitive nodes use direct value and type equality checks. Type mismatches (e.g., a key that was a string in the original but became an array in the modified) are reported as modifications with both old and new values displayed. This recursive composition naturally handles deeply nested structures like GraphQL responses, Elasticsearch query results, and Kubernetes manifests. Common use cases include comparing API response snapshots before and after code changes, validating configuration drift between staging and production environments, and auditing schema migrations in database export files.
Common questions and expert answers regarding this tool.
PrettyJSON uses a semantic diff engine that compares objects by key name (ignoring key order per RFC 8259) and arrays using LCS (Longest Common Subsequence) sequence alignment. This produces accurate results without false positives from key reordering or array index shifting.
Yes. Unlike basic tools that compare arrays index-by-index (where inserting one element cascades false changes), PrettyJSON uses LCS alignment to precisely identify which elements were inserted, deleted, or modified without affecting unrelated elements.
No. Per RFC 8259 §4, JSON objects are unordered collections. PrettyJSON treats {"a":1,"b":2} and {"b":2,"a":1} as identical, reporting zero differences. Only actual value changes, added keys, or removed keys are flagged.