Jsondiffpatch
by benjamine
The jsondiffpatch project's diff-mcp server hands an agent a single, format-flexible diff tool that compares text, JSON, YAML, TOML, XML, or HTML and returns a readable delta.
Add to Claude Code
claude mcp add diff -- npx -y diff-mcp
Source: https://github.com/benjamine/jsondiffpatch/tree/master/packages/diff-mcp
About
jsondiffpatch is a JavaScript library for diffing and patching objects, computing a small delta between two values, applying that delta, or rolling it back, and its diff-mcp package exposes that comparison logic to any MCP client as a single tool. You pass a left and right value, each optionally tagged with its format (text, json, json5, yaml, toml, xml, or html), and get back a diff in whichever output format you need: jsondiffpatch's own delta format, a plain-text readable diff, or an RFC 6902-style JSON Patch.
Because it accepts multiple structured formats and can normalize between them before comparing, it's useful for cases a plain text-diff tool handles badly, such as comparing a YAML config against a JSON one, or a JSON payload against an XML equivalent, without writing a conversion step yourself. The jsonpatch output mode in particular makes the result directly consumable by anything that already knows how to apply a standard JSON Patch.
Key features
- Single diff tool that accepts text, JSON, JSON5, YAML, TOML, XML, or HTML on either side
- Three output modes: jsondiffpatch delta, plain text, or RFC 6902 JSON Patch
- Text comparison backed by Google's diff-match-patch algorithm
- No server-side state, each call is a self-contained comparison
- Zero-install usage via npx
- Built on the mature, widely used jsondiffpatch diff/patch/unpatch library
Use cases
- Having an agent explain what changed between two versions of a config file in different formats
- Comparing API responses across environments, like staging vs. prod, regardless of their serialization format
- Generating a JSON Patch an agent or another tool can apply directly, instead of a human-readable-only diff
- Spotting drift between a YAML source of truth and a JSON snapshot without a manual conversion step
Available tools
diff
Compares a left and right value, each optionally in text, json, json5, yaml, toml, xml, or html, and returns the delta.
outputFormat: jsonpatch
A mode of the diff tool that returns the result as a standard JSON Patch (RFC 6902) instead of jsondiffpatch's own delta format, so it can be applied by any compliant patch tool.
Frequently asked questions
Can it compare a YAML file against a JSON file directly?
Yes. You set leftFormat and rightFormat independently, so the two sides don't need to be in the same format before comparison.
What's the difference between the output formats?
text gives a human-readable diff, json returns jsondiffpatch's own compact delta object, and jsonpatch returns an RFC 6902-style patch that other standard tools can apply directly.