I mean, you could stringify them both and check if they are equal or not… would be a quick and dirty way. Answer from Thalimet on reddit.com
🌐
Js
json-diff-kit.js.org
JSON Diff Kit Playground
We cannot provide a description for this page right now
🌐
npm
npmjs.com › package › json-diff-kit
json-diff-kit - npm
pnpm add terminal-kit # or make sure it's already installed in your project # Compare two JSON files, output the diff data to the terminal. # You can navigate it using keyboard like `less`. jsondiff run path/to/before.json path/to/after.json ...
      » npm install json-diff-kit
    
Published   Mar 03, 2026
Version   1.0.35
Author   Rex Zeng
🌐
GitHub
github.com › rawatanimesh › angular-json-diff-jdd
GitHub - rawatanimesh/angular-json-diff-jdd: Custom angular component of www.jsondiff.com library.
This angular compoent has been created using source code from http://www.jsondiff.com/ tool. This is a reusable angular component which helps in showing differences between two JSON objects.
Starred by 9 users
Forked by 8 users
Languages   JavaScript 64.8% | TypeScript 18.3% | CSS 9.2% | HTML 6.4% | SCSS 1.3%
🌐
Stack Overflow
stackoverflow.com › questions › 78650965 › showcasing-deepdiff-results-in-json-content-as-highlights-using-angular
jsonserializer - Showcasing deepDiff results in json content as highlights using Angular? - Stack Overflow
compareFiles() { if (this.file1Content && this.file2Content) { const differences = deepDiff.diff(this.file1Content.apis, this.file2Content.apis); if (differences) { this.comparisonResult = this.formatDifferences(differences); const filteredDifferences = differences.filter(diff => diff.path && !diff.path.some(p => p.key === 'index' && p.ignoreOrder)); this.comparisonResult2 = filteredDifferences ? JSON.stringify(filteredDifferences, null, 2) : 'No differences found.'; this.highlightedFile1Content = this.getHighlights(this.file1Content, differences); this.highlightedFile2Content = this.getHighlights(this.file2Content, differences); } } }
🌐
Rexskz
blog.rexskz.info › json-diff-kit-a-combination-of-several-simple-algorithms.html
JSON Diff Kit: A Combination of Several Simple Algorithms | Blog | Powered by skywalker_z
To decouple the diff and display logic, I write a Differ class to calculate the diff result and a Viewer component to display the diff result. I package these logics to a library json-diff-kit (a more complex usage is here), developers can use this library easily:
🌐
CodeSandbox
codesandbox.io › examples › package › json-diff-kit
json-diff-kit examples - CodeSandbox
Use this online json-diff-kit playground to view and fork json-diff-kit example apps and templates on CodeSandbox.
Top answer
1 of 2
2

The only built in operation for object comparison is the ==/=== equality operators, which use reference equality: A is B, rather than A is equal to B.

What you want is a list of change descriptors describing the difference between two objects.

As identified in the comments, this is going to need a recursive traversal of the objects, using a mixture of reference and existence checks.

The following algorithm is a quick implementation of an idea. The objects are traversed and their changes are described with a list of objects. Just like the objects themselves, the changes are nested, but have a unique id, based on their location within the object (so it could be flattened).

function diff(a, b, namespace) {
  namespace = (namespace || '') + '.';

  var keysInA = Object.keys(a),
      keysInB = Object.keys(b);

  var diffA = keysInA.reduce(function(changes, key) {
    var ns = namespace + key;

    if(typeof b[key] == 'undefined') {
      return changes.concat([{ type: 'DELETED', id: ns }]);
    }

    if(a[key] !== b[key]) {
      return changes.concat([{ type: 'CHANGED', id: ns }]);
    }

    if(typeof a[key] == b[key] == 'object') {
      return diff(a[key], b[key], ns);
    }

    return changes; 
  }, []);

  var diffB = keysInB.reduce(function(changes, key) {
    var ns = namespace + key;

    if(typeof a[key] == 'undefined') {
      return changes.concat([{ type: 'ADDED', id: ns }]);
    }

    return changes;
  }, []);

  return diffA.concat(diffB);
}

For example we take the original state of an object.

var a = { a: 1, b: 2, c: 3 };

And the new state.

var b = { a: 2, c: 3, d: 5 };

Then run them with the diff function.

diff(a, b);

It returns a list of the changes.

[
  { id: '.a', type: 'CHANGED' },
  { id: '.b', type: 'DELETED' },
  { id: '.d', type: 'ADDED' }
]

Obviously, you would have to adapt this algorithm to make it fit your criteria for what constitutes a change. You might want to look at deep equality, rather than comparing references the whole way down.

2 of 2
0

I'll add my implementation of Dan's suggestion here in case it will help someone who wants to see an actual implementation:

var propertiesToIgnore = ['.indexesTracked', '.notInSyncWithDb', '.date', '.details.updatedAt', '.autoLoadLocalStorage', '.deletionQueue']; //these are extraneous properties added to project that should not be represented in interface (and not tracked)
var keysToIgnore = ['addAllDatacuts', 'datacutNames']; // this just looks at the property rather than the above which matches from the project root

function diff(a, b, namespace, firstCall) {
    namespace = firstCall ? (namespace || '') : (namespace || '') + '.';

    var keysInA = Object.keys(a),
        keysInB = Object.keys(b);

    var diffA = keysInA.reduce(function(changes, key) {
      var ns = namespace + key;

      if (propertiesToIgnore.indexOf(ns) !== -1 || keysToIgnore.indexOf(key) !== -1) {
        return changes;
      }

      if (key == '$$hashKey') {
        return changes;
      }

      if (angular.equals(a[key], b[key])) { // whole chain is equal so I do not need to iterate over this branch
        return changes;
      }

      if (typeof b[key] == 'undefined') {
        return changes.concat([{ type: 'DELETED', id: ns }]);
      }

      if (a[key] !== b[key] && (typeof b[key] !== 'object' || typeof a[key] !== 'object')) {
        return changes.concat([{ type: 'UPDATED', id: ns }]);
      }

      if (typeof b[key] === 'object' && typeof a[key] === 'object') {
        return changes.concat(diff(a[key], b[key], ns));
      }
      if (a[key] === null || b[key] === null) { // avoids values that are null as js considers null an object
        return changes;
      }

      if(typeof a[key] == 'object' && typeof b[key] == 'object' && typeof a[key].getMonth !== 'function' && typeof b[key].getMonth !== 'function') { // last part necessary to make sure it is not a date object
        return diff(a[key], b[key], ns);
      }

      return changes;
    }, []);

    var diffB = keysInB.reduce(function(changes, key) {
      var ns = namespace + key;

      if (propertiesToIgnore.indexOf(ns) !== -1 || keysToIgnore.indexOf(key) !== -1) {
        return changes;
      }

      if (key == '$$hashKey') {
        return changes;
      }

      if (typeof a[key] == 'undefined') {
        return changes.concat([{ type: 'ADDED', id: ns }]);
      }

      return changes;
    }, []);

    return diffA.concat(diffB);
  }

  $scope.changes = diff(dbData, $scope.project, '');
🌐
GitHub
github.com › hipster-labs › angular-object-diff
GitHub - hipster-labs/angular-object-diff: An Angular JS plugin to compare and show object differences. Demo-
toJsonDiffView: format a diff object to a JSON formatted view with only changes · objToJsonView: format any javascript object to a JSON formatted view ... angular.module('myModule') .controller('MyController', ['$scope', 'ObjectDiff', function($scope, ObjectDiff){ $scope.yourObjectOne = {//all your object attributes and values here}; $scope.yourObjectTwo = {//all your object attributes and values here}; // This is required only if you want to show a JSON formatted view of your object without using a filter $scope.yourObjectOneJsonView = ObjectDiff.objToJsonView($scope.yourObjectOne); $scope.y
Starred by 33 users
Forked by 13 users
Languages   JavaScript 63.4% | HTML 31.8% | CSS 4.8%
Find elsewhere
🌐
GitHub
github.com › mufasa-dev › Json-diff
GitHub - mufasa-dev/Json-diff: 🔵🟠 An Angular-powered tool to quickly compare two JSON objects and highlight their differences!
📝 Compare Two JSONs – Find added, removed, or changed keys instantly. 📦 Support for JavaScript & TypeScript objects – Parse and compare exported objects or classes directly. Color Highlighting – Visual differences with clear color coding. 🔄 Recursive Comparison – Works with nested objects and arrays. ⚡ Fast and Lightweight – Built with Angular, no backend required.
Author   mufasa-dev
🌐
GitHub
github.com › msalehisedeh › differentiate
GitHub - msalehisedeh/differentiate: Angular - Graphical view to differentiate two JSON Objects
Take a look at the demo and enjoy the ride. Differentiate is an Angular based code and will interpret changes deep in JSON hierarchy through visual representation of changes on both sides.
Starred by 5 users
Forked by 4 users
Languages   TypeScript 64.2% | SCSS 27.1% | HTML 8.7%
🌐
npm
npmjs.com › package › angular-object-diff
angular-object-diff - npm
// you can directly diff your objects js now or parse a Json to object and diff · var diff = ObjectDiff.diffOwnProperties($scope.yourObjectOne, $scope.yourObjectTwo); // you can directly diff your objects including prototype properties and inherited properties using `diff` method · var diffAll = ObjectDiff.diff($scope.yourObjectOne, $scope.yourObjectTwo); ... Bind the variables directly in your html using the ng-bind-html angular directive.
      » npm install angular-object-diff
    
Published   Mar 11, 2016
Version   1.0.3
Author   Deepu K Sasidharan
🌐
GitHub
github.com › pbaumstarck › JSON-Diff
GitHub - pbaumstarck/JSON-Diff: An AngularJS application for creating a visual diff between two JSON objects.
An AngularJS application for creating a visual diff between two JSON objects. - pbaumstarck/JSON-Diff
Author   pbaumstarck
🌐
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.
🌐
npm
npmjs.com › package › json-diff-ts
json-diff-ts - npm
Calculate and apply differences between JSON objects with advanced features like key-based array diffing, JSONPath support, and atomic changesets.. Latest version: 4.10.0, last published: 3 days ago.
      » npm install json-diff-ts
    
Published   Mar 06, 2026
Version   4.10.0
Author   Christian Glessner
🌐
GitHub
github.com › rars › ngx-diff › blob › main › angular.json
ngx-diff/angular.json at main · rars/ngx-diff
Angular component library for displaying diffs of text. - ngx-diff/angular.json at main · rars/ngx-diff
Author   rars
🌐
Quora
quora.com › How-do-I-compare-JSON-objects-in-Angular
How to compare JSON objects in Angular - Quora
Answer: Angular has actually nothing to do (directly) with comparing JSON data. JSON is a subset of JS literal syntax for describing objects, but it is a textual representation of those.
🌐
npm
npmjs.com › package › jsondiffpatch
jsondiffpatch - npm
JSON diff & patch (object and array diff, text diff, multiple output formats). Latest version: 0.7.3, last published: a year ago. Start using jsondiffpatch in your project by running `npm i jsondiffpatch`. There are 587 other projects in the npm registry using jsondiffpatch.
      » npm install jsondiffpatch
    
Published   Mar 31, 2025
Version   0.7.3
Author   Benjamin Eidelman