JSON Diff
Compare two JSON documents and inspect their values.
Your result will appear here…
How to use JSON Diff
- Paste the first JSON document.
- Add a line containing only --- (three hyphens, nothing else) below it, then paste the second document.
- Select Compare and read the − and + lines.
Example
Input / settings:
{"name":"Ada","role":"engineer"}
---
{"name":"Ada","role":"designer"}Output:
{
"name": "Ada",
− "role": "engineer"
+ "role": "designer"
}Both sides are re-serialized before comparison, so indentation and spacing in the pasted text never appear as differences.
When to use
- Check what changed between two API responses after a deployment.
- Review a configuration file before and after an edit.
- Confirm that two serializers produce the same data even though their whitespace differs.
Overview
JSON Diff parses two JSON documents, re-serializes each with two-space indentation, and compares the results line by line. Matching lines start with two spaces; where a line differs, the first document's line is marked − and the second document's line is marked +. This is a text comparison of normalized JSON, not a structural diff, so it does not track which key moved or which array element was inserted.
Supported input
Two strict JSON documents (RFC 8259) separated by a line containing only ---. Only the first two documents are compared.
Output details
The first document is compared with the second line by line after both are re-serialized with two-space indentation. Changed lines are marked − and +.
Common mistakes
- Moving keys is reported as a change: {"a":1,"b":2} against {"b":2,"a":1} marks the a and b lines as different even though both objects hold the same data.
- Inserting an array element shifts every later line. Adding "w" to the front of ["x","y"] marks the following values and the closing bracket as changed, so a small edit can look like a large one.
- Large integers are rounded by JSON.parse before comparison. 12345678901234567890 and 12345678901234567891 both become 12345678901234567000, so no difference is shown. Send such identifiers as strings.
- When the documents have different line counts, the extra lines at the end show up as a − with nothing after it (second document longer) or as a trailing empty line (first document longer). They are padding, not content.
- Only the first two documents are compared. A third document after another --- line is ignored without a warning.
Practical tips
- Put keys in the same order in both documents first when their order has no meaning.
- Use Text Diff when you need a plain-text comparison of content that is not JSON.
Privacy and security
This tool runs entirely in your browser. Your input is never uploaded to our servers. Parsing uses your browser's JSON.parse, so error wording for invalid JSON can differ between browsers. If a document repeats a key, the last value wins, so {"a":1,"a":2} is compared as {"a":2}; RFC 8259 calls the behavior of repeated names unpredictable, so avoid relying on it.
References
Frequently asked questions
How do I separate the two JSON documents?
Put --- alone on its own line between them, with no spaces around it and not at the very start or end of the input. Without a recognized separator the tool asks you to add one.
Are number formats such as 1 and 1.0 reported as different?
No. Both parse to the same number and serialize as 1, so formatting differences in numbers are not shown.
Can I compare JSON with comments or trailing commas?
No. The input must be strict JSON as defined by RFC 8259, so comments and trailing commas are reported as parse errors.