JSON DIFF
JSON 对比,按路径找出差异。
比较两份 JSON,按路径查看新增、删除、变更与移动;对象数组可智能按稳定 ID 对齐,也可改为按下标比较。全程本地处理,不上传数据。
智能模式优先按共有且唯一的 id/key 匹配对象数组;否则按相同元素对齐,再比较剩余位置。
怎么用?
粘贴或从本地导入两份 JSON 后点击「对比」。智能模式会匹配稳定 ID 并标出移动;切换为按下标比较可保留数组位置语义。路径可复制,长值可展开。
常见问题
它安全吗?数据会上传吗?
全程在浏览器本地运行,不会上传你的任何数据。
支持哪些设备?
只要是现代浏览器(手机 / 平板 / 电脑)均可使用,无需安装。
示例与注意事项Example & notes
一个例子A worked example
排查接口改版:左侧导入或粘贴旧 JSON,右侧放新版本;对象数组可按唯一 id 自动匹配,按路径查看新增、删除、变更与移动,点路径复制,还能展开完整值并下载报告。Check an API revision: load or paste the old JSON on the left and the new version on the right. Object arrays can match by a unique id; inspect additions, removals, changes and moves by path, expand full values, and download a report.
注意事项Things to watch
- 智能模式优先按两侧共有且唯一的标量 id、uuid、key 等字段匹配对象数组,并识别移动;否则尝试对齐相同元素。若数组下标代表业务含义,可切换「按下标比较」。Smart mode matches object arrays by a shared, unique scalar id, uuid or key and detects moves; otherwise it aligns identical items where possible. Choose index mode when positions carry meaning.
- 对象键顺序不算差异;重复键会由 JSON.parse 保留最后一个值。1 与 1.0 会解析为同一数值,超过安全整数范围的大整数可能丢精度,建议按字符串保存。Object key order is ignored, and JSON.parse keeps only the last duplicate key. 1 and 1.0 parse as the same number; integers beyond JavaScript’s safe range can lose precision, so preserve them as strings.
- 注释、尾随逗号等非标准 JSON 会解析失败;单侧最多 2 MiB、嵌套最多 100 层。文件只在本机读取,导出的报告含差异值,分享前请检查敏感字段。Comments, trailing commas and other non-standard JSON fail to parse. Each side is limited to 2 MiB and 100 nesting levels. Files stay local; exported reports contain changed values, so review sensitive fields before sharing.
相关问答More Q&A
两个 JSON 怎么对比才准?How do I get an accurate JSON diff?
两边都只放纯 JSON(不要外层包裹对象名),确认缩进与键名完全一致;如果一个是接口返回、一个是配置文件,先把结构对齐再比,否则差异会被结构性错位淹没。Put plain JSON on both sides (no wrapper object), make sure indentation and key names match, and align the structure first when one side is an API response and the other a config file — otherwise structural mismatches drown out the real changes.
智能模式如何对齐数组?How does smart mode align arrays?
对象数组先尝试使用两侧共有且唯一的 id/key 等标量字段;没有可用稳定字段时,会匹配完全相同的元素,再按位置比较未匹配片段。重复键或同时大幅改动会降低匹配确定性;需要严格位置语义时请选择「按下标比较」。Object arrays first try a shared, unique scalar id/key. Without one, identical items are aligned before unmatched sections are compared positionally. Duplicate keys or many simultaneous edits make matching less certain; choose index mode when positions must be compared strictly.
JSON 文件会上传吗?报告能直接分享吗?Are JSON files uploaded, and are reports safe to share?
不会上传,比较和本地文件读取都在浏览器中进行。复制或下载的报告包含差异路径和值;对外分享前应先检查并移除令牌、个人信息等敏感内容。No. Comparison and local-file reading happen in your browser. Copied or downloaded reports include difference paths and values; remove tokens, personal data and other sensitive content before sharing.