JSON Compare / Diff + Patch

在瀏覽器中語意比較兩個 JSON 檔案,並將差異轉換成補丁。

無需上傳,也無需往返伺服器。透過陣列感知比較模式、路徑規則和數值容差來減少雜訊。

僅在瀏覽器內處理,不上傳到伺服器
陣列感知模式可減少審查雜訊
可匯出 JSON Patch 與 JSON Merge Patch
所有內容都留在你的瀏覽器工作階段中,不會被上傳。

Recommended workflow

  1. Clean or sort the JSON first with JSON Formatter or JSON Key Sorter when you want consistent input.
  2. Paste or upload the left and right JSON documents, then run Compare.
  3. Choose the array mode, match keys, tolerance, and path rules that fit the review.
  4. Review the summary, changed paths, tree, and exportable patch output.

示例

這個示例展示瞭如何用匹配鍵、容差和路徑規則,把陣列重排、時間戳變化、微小浮點差異以及新增項縮小到更清晰的差異範圍。

之前

輸入
{
  "orderId": "A-1001",
  "updatedAt": "2026-04-16T08:00:00Z",
  "customer": {
    "name": "Acme Corp",
    "tags": ["vip", "beta"]
  },
  "items": [
    {
      "sku": "A-1",
      "qty": 2,
      "price": 10
    },
    {
      "sku": "B-2",
      "qty": 1,
      "price": 4.5
    }
  ],
  "summary": {
    "currency": "USD",
    "total": 24.5
  }
}

之後

輸入
{
  "orderId": "A-1001",
  "updatedAt": "2026-04-16T08:05:00Z",
  "customer": {
    "name": "Acme Corporation",
    "tags": ["beta", "vip"]
  },
  "items": [
    {
      "sku": "B-2",
      "qty": 1,
      "price": 4.5
    },
    {
      "sku": "A-1",
      "qty": 2,
      "price": 10.0001
    },
    {
      "sku": "C-3",
      "qty": 1,
      "price": 7
    }
  ],
  "summary": {
    "currency": "USD",
    "total": 24.5001
  }
}

示例說明

這個示例展示瞭如何用匹配鍵、容差和路徑規則,把陣列重排、時間戳變化、微小浮點差異以及新增項縮小到更清晰的差異範圍。

How to compare

  1. Paste or upload the left and right JSON documents.
  2. Choose strict, ignore order, multiset, or match by key(s), then add any path rules you need.
  3. Run Compare or use the shortcut. Validate first if you only want to check parsing.
  4. Copy or download the changed paths, patch, merge patch, or report when you are done.

你可以做什麼

  • 以語意方式比較 JSON,而不是逐列比較。
  • 可按 id、sku、code 等鍵去匹配陣列項。
  • 可忽略路徑、選擇路徑,或為不同路徑應用不同的比較規則。
  • 使用數值容差,減輕細微浮點差異帶來的雜訊。
  • 匯出 JSON Patch、JSON Merge Patch、變更路徑,以及 Markdown 報告。
  • 摺疊未變化的節點,並直接跳轉到相關路徑。

比較規則與輸出

  • 處理完全在瀏覽器內完成,不會上傳任何內容。
  • 支援嚴格、忽略順序、多重集合和依鍵匹配的陣列模式。
  • 路徑規則支援忽略、嚴格、忽略順序、多重集合、依鍵匹配和容差。
  • 數值容差僅應用於數字。
  • 需要時可以在解析前移除註釋。
  • 大輸入會使用先摘要後細節的渲染方式,並可禁用自動比較。

常見問題

我能依鍵比較物件陣列嗎?

可以。使用“依鍵匹配”,並列出如 id 或 sku 之類的鍵。也可以按路徑單獨覆蓋規則。

如何忽略時間戳或請求 ID?

把它們加入“忽略路徑”,或者在只希望某個子樹適用時使用路徑規則。

我能讓某些部分保留陣列順序,而忽略其他部分嗎?

可以。使用路徑規則,在需要的地方設定忽略順序、多重集合,或僅依鍵匹配。

它支援帶註釋的 JSON 嗎?

標準 JSON 不允許註釋。只有在需要接受 JSONC 風格輸入時,才啟用“解析前移除註釋”。

內容會上傳到伺服器嗎?

不會。比較、正規化和匯出都在你的瀏覽器本地完成。

我可以匯出什麼?

JSON Patch、JSON Merge Patch、變更路徑,以及 Markdown 報告。