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 报告。