JSON Diff & Patch

An open-source semantic tool to compare JSON documents to show diffs and apply patches using a free public API.

Quick Start >> Docs

Trusted by

Github logo
ACM logo
Musgrave logo
BN Logo
Grainger Logo
Bombora logo
Capital One Logo
IEEE logo
Trimble logo
Cognite Logo
Apiax logo
Elastic logo
ING logo
Cavai logo

JSON Diff & Patch Module overview

Extend the functionality of your MongoDB backend (or other databases) by adding schema informed JSON diff and patch functionality. 


When objects are modified in a distributed system, it is useful to be able to compare versions of an object to see what has changed according to the current knowledge about an object at some node.


This is where JSON diff and patch come in. Diff takes two JSON objects and constructs a difference between the two objects so that the second object can be obtained from the first by means of a patch operation.


The diff between two objects can also be used to display to a user a synopsis of differences, in what might otherwise be too large an object to see obviously where things changed. This enables either direct or user-interface assisted choice for how to proceed. This allows the user to retain the original, change to the new, or instead, supply a new change altogether. 


More: Tech Blog on JSON Diff & Patch



Example patch operation:


let diffPatch = await client.getDiff(
     { "@id": "Person/Jane", "@type": "Person", name: "Jane" },
     { "@id": "Person/Jane", "@type": "Person", name: "Janine" }

let patch = await client.patch( { "@id": "Person/Jane", "@type": "Person", name: "Jane" }, diffPatch);

JSON Diff & Patch Use Cases

The ability to compare JSON documents is useful to builders and users of applications, use cases include:

Build sense into your build

Developing a feature or new application with a team and need to compare JSON objects? Perhaps you need to validate data to understand the functional performance of your build. The TerminusDB JSON Diff & Patch Module enables you to perform schematically informed diff and patch operations directly with your backend.

Give users the power

Build user-interface-assisted JSON diff and patch functionality into your applications and give users the power to work as a team and keep their data accurate. This functionality is being used within an AI-assisted translation company that compares JSON diff translations to help the AI tool translate effectively with human reviews and approvals.

Approval checks

Where data is surfaced, be it for reporting, financial plans, product listings, or content management, having appropriate approval checks to ensure accuracy and data integrity is crucial. The TerminusDB JSON Diff & Patch Module enables you to add approval checks to data updates, so new product data on an e-commerce platform is correct, the latest report features the right number, or the case study features the right customer quote.

JSON Diff & Patch
A vision for how to build collaborative applications

TerminusDB CTO and Co-Founder, Gavin Mendel-Gleason, talks through data collaboration and how it should be done to build applications designed for collaboration.

TerminusDB Open Source Graph Database

Get started for free

No need to sign up, handover card details, this free service, built with TerminusX is available to bolt onto your MongoDB applications, read the documentation to get started.