It's not too hard to create a function like this. Just loop through each field in the second object, and if it's not present in the first or the value is different than the first, put that field in the return object.

var compareJSON = function(obj1, obj2) {
  var ret = {};
  for(var i in obj2) {
    if(!obj1.hasOwnProperty(i) || obj2[i] !== obj1[i]) {
      ret[i] = obj2[i];
    }
  }
  return ret;
};

You can see it in action on this demo page.

Answer from Peter Olson on Stack Overflow
🌐
npm
npmjs.com › package › json-diff-ts
json-diff-ts - npm
3 weeks ago - Modern TypeScript JSON diff library - json-diff-ts is a lightweight, high-performance TypeScript library for calculating and applying differences between JSON objects.
      » npm install json-diff-ts
    
Published   Mar 06, 2026
Version   4.10.0
Author   Christian Glessner
Discussions

Javascript JSON comparison/diff? - Stack Overflow
WHAT I HAVE TRIED: I have tried ... field to JSON B, I have to hardcode in the field I am looking for... that is why I am looking for something less of a pain. ... It's not too hard to create a function like this. Just loop through each field in the second object, and if it's not present in the first or the value is different than the first, ... More on stackoverflow.com
🌐 stackoverflow.com
Is there a library that allows to easily do diffchecks between two json?
I mean, you could stringify them both and check if they are equal or not… would be a quick and dirty way. More on reddit.com
🌐 r/reactjs
27
16
October 13, 2022
Semantic json diff library for .Net
I’ve used https://github.com/nrkno/Quibble for this recently. Seems to work well. I ended up writing some custom code to sort the JSON properties alphabetically before comparing which seemed to improve results for objects with a larger number of differences More on reddit.com
🌐 r/dotnet
5
9
April 15, 2025
jsondiff: JSON diff library for Go based on RFC6902 (JSON Patch)
To give a bit of context, I was working on a Kubernetes Dynamic Admission controller recently at work (a mutating webhook to be precise), and originally went the naive/easy way by crafting the patch "as it came", but realised that keeping context of which changes (in the sense of which JSON Patch operations were already added) were made previously was tedious. Instead, it made more sense to simply mutate the original `corev1.Pod` resource and generate the patch with the original and mutated version of the Pod object. Of course the library can be used for any other needs. The package is pretty much "complete features-wise". I am planning to add a WASM-based UI to test the library in a browser soon, mainly for fun. Feedback appreciated. More on reddit.com
🌐 r/golang
9
13
December 7, 2020
🌐
npm
npmjs.com › package › json-diff
json-diff - npm
% json-diff --help Usage: json-diff [-vCjfonskKp] first.json second.json Arguments: <first.json> Old file <second.json> New file General options: -v, --verbose Output progress info -C, --[no-]color Colored output -j, --raw-json Display raw JSON encoding of the diff -f, --full Include the equal sections of the document, not just the deltas --max-elisions COUNT Max number of ...s to show in a row in "deltas" mode (before collapsing them) -o, --output-keys KEYS Always print this comma separated keys, with their value, if they are part of an object with any diff -x, --exclude-keys KEYS Exclude these comma separated keys from comparison on both files -n, --output-new-only Output only the updated and new key/value pairs (without marking them as such).
      » npm install json-diff
    
Published   May 15, 2023
Version   1.0.6
Author   Andrey Tarantsov
🌐
JSON Diff
jsondiff.com
JSON Diff - The semantic JSON compare tool
Validate, format, and compare two JSON documents. See the differences between the objects instead of just the new lines and mixed up properties.
🌐
GitHub
github.com › benjamine › jsondiffpatch
GitHub - benjamine/jsondiffpatch: Diff & patch JavaScript objects · GitHub
or as a library: // sample data const country = { name: 'Argentina', capital: 'Buenos Aires', independence: new Date(1816, 6, 9), }; // clone country, using dateReviver for Date objects const country2 = JSON.parse(JSON.stringify(country), jsondiffpatch.dateReviver); // make some changes country2.name = 'Republica Argentina'; country2.population = 41324992; delete country2.capital; const delta = jsondiffpatch.diff(country, country2); assertSame(delta, { name: ['Argentina', 'Republica Argentina'], // old value, new value population: ['41324992'], // new value capital: ['Buenos Aires', 0, 0], //
Author   benjamine
🌐
Go Packages
pkg.go.dev › github.com › wI2L › jsondiff
jsondiff package - github.com/wI2L/jsondiff - Go Packages
May 9, 2025 - jsondiff is a Go package for computing the diff between two JSON documents as a series of RFC6902 (JSON Patch) operations, which is particularly suitable to create the patch response of a Kubernetes Mutating Webhook for example. First, get the latest version of the library using the following ...
🌐
GitHub
github.com › swaggest › json-diff
GitHub - swaggest/json-diff: JSON diff/rearrange/patch/pointer library for PHP · GitHub
JSON diff/rearrange/patch/pointer library for PHP. Contribute to swaggest/json-diff development by creating an account on GitHub.
Author   swaggest
Find elsewhere
🌐
PyPI
pypi.org › project › json-diff
json-diff · PyPI
Compares two JSON files (http://json.org) and generates a new JSON file with the result.
      » pip install json-diff
    
Published   Aug 25, 2019
Version   1.5.0
🌐
JSON for Modern C++
json.nlohmann.me › api › basic_json › diff
diff - JSON for Modern C++
#include <iostream> #include <iomanip> #include <nlohmann/json.hpp> using json = nlohmann::json; using namespace nlohmann::literals; int main() { // the source document json source = R"( { "baz": "qux", "foo": "bar" } )"_json; // the target document json target = R"( { "baz": "boo", "hello": [ "world" ] } )"_json; // create the patch json patch = json::diff(source, target); // roundtrip json patched_source = source.patch(patch); // output patch and roundtrip result std::cout << std::setw(4) << patch << "\n\n" << std::setw(4) << patched_source << std::endl; }
🌐
npm
npmjs.com › package › json-diff-kit
json-diff-kit - npm
November 23, 2025 - A better JSON differ & viewer library written in TypeScript.
      » npm install json-diff-kit
    
Published   Mar 03, 2026
Version   1.0.35
Author   Rex Zeng
🌐
DEV Community
dev.to › keploy › diff-json-a-complete-guide-to-comparing-json-data-3e31
Diff JSON – A Complete Guide to Comparing JSON Data - DEV Community
October 15, 2024 - • JSON-diff (npm library): This JavaScript package helps compare JSON objects and outputs differences. It’s widely used in Node.js environments. • Postman: A popular API testing tool that includes JSON comparison features.
🌐
Proxyman
proxyman.com › home › tools › diff
JSON Diff: Free Online JSON Diff Tool | Build by Proxyman
Free & Secure JSON Diff Tool. Compare JSON files side-by-side with syntax highlighting. All processing occurs locally in your browser - no data leaves your device.
Published   October 8, 2024
🌐
Go Packages
pkg.go.dev › github.com › nsf › jsondiff
jsondiff package - github.com/nsf/jsondiff - Go Packages
April 30, 2023 - The main purpose of the library is integration into tests which use json and providing human-readable output of test results. The lib can compare two json items and return a detailed report of the comparison. At the moment it can detect a couple of types of differences:
🌐
GitHub
github.com › nrkno › Quibble
GitHub - nrkno/Quibble: JSON diff tool for .NET
Quibble is a JSON diff tool for .NET.
Starred by 56 users
Forked by 3 users
Languages   C# 50.3% | F# 49.7%
🌐
GitHub
github.com › josephburnett › jd
GitHub - josephburnett/jd: JSON diff and patch · GitHub
jd is a commandline utility and Go library for diffing and patching JSON and YAML values. It supports a native jd format (similar to unified format) as well as JSON Merge Patch (RFC 7386) and a subset of JSON Patch (RFC 6902).
Author   josephburnett
🌐
JSON Diff
json-diff.com
JSON Diff - Compare and Find Differences in JSON Files Online
JSON Diff is a free and open-source tool to compare two JSON objects and find differences. Visualize changes in JSON files, easy and fast.
🌐
JSON Compare
jsoncompare.org
JSON Compare - Best JSON Diff Tools
JSON Compare helps to Compare and find diff in JSON data.
🌐
SemanticDiff
semanticdiff.com › online-diff › json
SemanticDiff - Online JSON Diff
The tool compares JSON objects and arrays by first parsing them into a data structure that is independent of their textual representation. This helps us ignore changes that are unrelated to the encoded values, such as adding optional commas or whitespace outside of strings.