≠

JSON Difference Viewer

Compare two JSON documents and list added, removed, and changed values

JSON Difference Viewer — what it does

Compare two JSON documents and get a structured list of what was added, what was removed and which values changed, with the path to each difference. Comparing JSON as text is hopeless because key order and formatting vary; comparing it structurally tells you what actually differs.

Worked example

Two versions of an invoice record compared: the second raises the total, adds a second line item and adds a due date.

Input — First JSON (A) and Second JSON (B)

First JSON
{"invoice":"INV-2041","customer":"Ann Lee","total":1200,"lines":[{"sku":"NB-100","qty":2}],"paid":false}

Second JSON
{"invoice":"INV-2041","customer":"Ann Lee","total":1350,"lines":[{"sku":"NB-100","qty":2},{"sku":"DL-300","qty":1}],"paid":false,"due":"2026-11-15"}

Output — json-differences.json (3 difference(s))

[
  {
    "path": "$.total",
    "type": "changed",
    "before": 1200,
    "after": 1350
  },
  {
    "path": "$.lines[1]",
    "type": "added",
    "after": {
      "sku": "DL-300",
      "qty": 1
    }
  },
  {
    "path": "$.due",
    "type": "added",
    "after": "2026-11-15"
  }
]

The on-page table shows the same three rows with path, type, before and after. Added entries carry only an after value; removed ones would carry only before.

When this tool helps

  • Seeing what changed between two API responses captured before and after a deployment.
  • Diffing configuration files across environments to find the setting that differs.
  • Verifying that a data transformation changed only the fields it was supposed to.

How to use it

  1. Paste the first JSON document.
  2. Paste the second JSON document.
  3. Process the comparison.
  4. Review added, removed and changed entries, then download the result.

Accuracy, limits, and good practice

  • Key order and indentation are ignored, so two documents that are formatted differently but structurally identical show no differences at all.
  • Arrays are compared by position, so an inserted element early in a list marks everything after it as changed.
  • An empty difference list is a real result: it proves two payloads are semantically identical despite any textual differences.

Frequently asked questions

Why does a text diff show changes when this does not?

Because text diffing sees reordered keys and whitespace as changes. Structural comparison looks only at meaning.

Can it handle deeply nested documents?

Yes, comparison recurses through the structure and reports the full path to each difference.

What about arrays of objects that were reordered?

Positional comparison reports those as changes. Sort both arrays by a stable key first for a meaningful diff.

What does the downloaded report contain?

One object per difference with path, type and the values: for added entries only after is present and for removed entries only before, as the example shows. When the count is 0 nothing is downloaded.

How is a change of type reported?

As a single changed entry at that path with the whole old and new values, rather than descending into it: a number that becomes a string, or an object replaced by null, produces one line. Documents with the same keys in a different order report 0 difference(s).

Related tools on this site

Everything above runs inside this page. JSON Difference Viewer needs no account, no upload, and no server round trip — close the tab and nothing is left behind.

JSON 差異檢視器能做什麼

比較兩份 JSON 文件,得到結構化的清單:新增了什麼、移除了什麼、哪些值有變動,並附上每處差異的路徑。把 JSON 當文字比對毫無希望,因為鍵順序與排版都會變;用結構比較,才看得出真正的差異。

實際範例

比較同一張發票紀錄的兩個版本:第二版提高了總額、多了一個品項,並加了到期日。

來源:First JSON(A)與 Second JSON(B)

First JSON
{"invoice":"INV-2041","customer":"Ann Lee","total":1200,"lines":[{"sku":"NB-100","qty":2}],"paid":false}

Second JSON
{"invoice":"INV-2041","customer":"Ann Lee","total":1350,"lines":[{"sku":"NB-100","qty":2},{"sku":"DL-300","qty":1}],"paid":false,"due":"2026-11-15"}

產生的檔案:json-differences.json(3 difference(s))

[
  {
    "path": "$.total",
    "type": "changed",
    "before": 1200,
    "after": 1350
  },
  {
    "path": "$.lines[1]",
    "type": "added",
    "after": {
      "sku": "DL-300",
      "qty": 1
    }
  },
  {
    "path": "$.due",
    "type": "added",
    "after": "2026-11-15"
  }
]

頁面上的表格列著同樣三筆,含 path、type、before、after。added 的項目只有 after 值;removed 的則只會有 before。

什麼時候用得上

  • 查看部署前後擷取的兩份 API 回應之間有何變化。
  • 比對不同環境的設定檔,找出差異的那一項設定。
  • 驗證資料轉換只改動了預期中的欄位。

使用步驟

  1. 貼上第一份 JSON 文件。
  2. 貼上第二份 JSON 文件。
  3. 執行比較。
  4. 檢視新增、移除與變更項目,再下載結果。

精確度、限制與實務建議

  • 鍵順序與縮排都會被忽略,因此排版不同但結構相同的兩份文件不會出現任何差異。
  • 陣列依位置比較,早段插入一個元素會讓其後全部被標為變動。
  • 「沒有差異」是有意義的結果:它證明兩份載荷在語意上完全相同,即使文字不同。

常見問題

為什麼文字比對有差異、這裡卻沒有?

因為文字比對會把鍵順序與空白視為變動;結構比較只看語意。

能處理很深的巢狀文件嗎?

可以,比較會遞迴走訪結構,並回報每處差異的完整路徑。

物件陣列被重新排序怎麼辦?

依位置比較會把它們全報成變動。請先依穩定鍵值排序兩邊陣列,比對才有意義。

下載的報告裡有什麼?

每個差異一個物件,含 path、type 與前後值:added 的只有 after,removed 的只有 before,如範例所示。計數為 0 時不會下載任何東西。

型別改變時怎麼呈現?

在該路徑記為單一筆 changed,附上整個舊值與新值,不再往內比:數字變字串、物件被換成 null,都只產生一行。鍵順序不同但內容相同的兩份文件會得到 0 difference(s)。

本站相關工具

以上步驟全部在這個頁面內完成,JSON 差異檢視器 不需要註冊、不上傳檔案、也不經過伺服器,關閉分頁後不會留下任何資料。