Skip to content
PithLab

↑↓ to move · Enter to open · Esc to close

JSON Diff: Compare JSON and Create a JSON Patch

Structural JSON comparison with paths, a side-by-side view and JSON Patch output.

Use via API

Compare two JSON documents structurally: lists added, removed, changed and moved values with JSONPath-style paths, plus an RFC 6902 JSON Patch that turns the original into the changed document. Send JSON, get JSON back.

POST https://pithlab.com/api/v1/tools/json-diff

curl https://pithlab.com/api/v1/tools/json-diff \
  -H "Authorization: Bearer $PITHLAB_KEY" \
  -H "Content-Type: application/json" \
  -d '{"original":"{\"name\":\"Ada\",\"roles\":[\"admin\"],\"meta\":{\"updatedAt\":\"2026-01-01\"}}","changed":"{\"name\":\"Ada Lovelace\",\"roles\":[\"admin\",\"editor\"],\"meta\":{\"updatedAt\":\"2026-02-01\"}}","ignorePaths":"$.meta.updatedAt"}'

Fields and responseOpenAPI documentGet an API key

About the JSON Diff

Compare two JSON documents by structure, not text. See added, removed and changed paths side by side, match arrays by id, ignore paths and export an RFC 6902 patch.

How to use the JSON Diff

  1. Paste the original JSON on the left and the changed JSON on the right, or press Example.
  2. If arrays hold objects with an id, enter that field in Match array items by so reordered items are paired up.
  3. List any paths to ignore, such as $.meta.updatedAt, $.items[*].etag or $..timestamp.
  4. Switch between the change list, the side-by-side view and the JSON Patch, then copy or download the result.

Examples

Changed, added and removed values (original on line 1, changed on line 2)

Input

{"name":"Ada","role":"admin","tags":["math","code"],"active":true}
{"name":"Ada","role":"owner","tags":["math","code","poetry"],"email":"[email protected]"}

Output

~ $.role: "admin" → "owner"
+ $.tags[2]: "poetry"
- $.active: true
+ $.email: "[email protected]"
JSON Patch with array items matched by id

Input

{"items":[{"id":1,"qty":2},{"id":2,"qty":1}]}
{"items":[{"id":2,"qty":1},{"id":1,"qty":3},{"id":3,"qty":5}]}

Output

[
  {
    "op": "replace",
    "path": "/items/0/qty",
    "value": 3
  },
  {
    "op": "move",
    "from": "/items/1",
    "path": "/items/0"
  },
  {
    "op": "add",
    "path": "/items/2",
    "value": {
      "id": 3,
      "qty": 5
    }
  }
]

Frequently asked questions

How is this different from a text diff?

It compares the data, not the characters. Key order and formatting never count as changes, so two documents that only differ in spacing or key order are reported as identical.

What does matching array items by a key do?

By default arrays are compared position by position, so inserting one item at the start makes every later item look changed. With a key such as id, items are paired by that value, so you see the one added item, real edits and any moves instead.

How do I write paths to ignore?

Use the same style as the results: $.meta.updatedAt for one key, $['odd key'] for keys with spaces, $.items[*].etag for a field in every array item and $..timestamp for a key at any depth. Separate several paths with commas or new lines.

What is the JSON Patch output?

An RFC 6902 JSON Patch: a list of add, remove, replace and move operations that turns the original document into the changed one. Array removals come from the end first so every index stays valid. Ignored paths are left out of the patch.

Is my JSON uploaded?

No. Both documents are parsed and compared in your browser, so API responses and config files never leave your device.