🌐
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
🌐
npm
npmjs.com › package › compare-json
compare-json - npm
February 7, 2019 - Compares two or more JSON files for missing object keys, useful for checking i18n language files.. Latest version: 0.4.0, last published: 7 years ago. Start using compare-json in your project by running `npm i compare-json`. There are 1 other ...
      » npm install compare-json
    
Published   Feb 07, 2019
Version   0.4.0
Author   Nolemmings
🌐
npm
npmjs.com › package › json-diff-ts
json-diff-ts - npm
1 month ago - Modern TypeScript JSON diff library - Zero dependencies, high performance, ESM + CommonJS support. 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
🌐
npm
npmjs.com › package › react-json-view-compare
react-json-view-compare - npm
import ReactJsonViewCompare from 'react-json-view-compare'; const oldData = { name: 'super', age: 18, task: [ { name: 'eat', time: '09:00' }, { name: 'work', time: '10:00' }, { name: 'sleep', time: '22:00' } ] }; const newData = { name: 'coolapt', age: 20, task: [ { name: 'eat', time: '09:00' }, { name: 'work', time: '10:00' }, { name: 'sleep', time: '23:00' }, { name: 'running', time: '08:00' } ] }; function App() { return <ReactJsonViewCompare oldData={oldData} newData={newData} />; } ReactDOM.render(<App />, document.getElementById('root'));
      » npm install react-json-view-compare
    
Published   Mar 30, 2023
Version   2.0.2
Author   coolapt
🌐
npm
npmjs.com › package › json-diff-kit
json-diff-kit - npm
November 23, 2025 - You can use the CLI tool to generate the diff data from two JSON files. Please install the package terminal-kit before using it. pnpm add terminal-kit # or make sure it's already installed in your project # Compare two JSON files, output the ...
      » npm install json-diff-kit
    
Published   Mar 03, 2026
Version   1.0.35
Author   Rex Zeng
🌐
npm
npmjs.com › search
keywords:json compare - npm search
Library to compare two (JSON-serializable) structures and return their differences.
🌐
npm
npmjs.com › package › diff-json
diff-json - npm
npm · Sign UpSign In · 2.0.0 • Public • Published 7 years ago · Readme · Code Beta · 4 Dependencies · 17 Dependents · 18 Versions · A diff tool for javascript objects inspired by https://github.com/eugeneware/changeset.
      » npm install diff-json
    
Published   May 13, 2019
Version   2.0.0
Author   viruschidai@gmail.com
🌐
npm
npmjs.com › package › json-schema-diff
json-schema-diff - npm
Latest version: 1.0.0, last published: 3 months ago. Start using json-schema-diff in your project by running `npm i json-schema-diff`. There are 5 other projects in the npm registry using json-schema-diff.
      » npm install json-schema-diff
    
Published   Nov 21, 2025
Version   1.0.0
Author   Ben Sayers
🌐
npm
npmjs.com › search
keywords:compare JSON - npm search
Library to compare two (JSON-serializable) structures and return their differences.
🌐
GitHub
github.com › lukascivil › json-difference
GitHub - lukascivil/json-difference: A simple way to find the difference between two objects or json diff · GitHub
import { getDiff } from 'json-difference' const coffee = { color: { color1: 'black', color2: 'brown' }, special: true } const oil = { color: { color1: 'red', color2: 'blue' }, special2: false, especial3: [{}] } // Get JsonDiff delta const diff = getDiff(coffee, oil) const diff2 = getDiff(coffee, oil, { isLodashLike: true }) console.log(diff) console.log(diff2)
Starred by 57 users
Forked by 5 users
Languages   TypeScript 91.8% | JavaScript 7.3% | HTML 0.9%
Find elsewhere
🌐
npm
npmjs.com › package › json-difference
json-difference - npm
February 4, 2024 - json difference lib. Latest version: 1.16.1, last published: 2 years ago. Start using json-difference in your project by running `npm i json-difference`. There are 13 other projects in the npm registry using json-difference.
      » npm install json-difference
    
Published   Feb 04, 2024
Version   1.16.1
Author   lukascivil
🌐
npm
npmjs.com › package › vue-json-compare
vue-json-compare - npm
August 20, 2020 - A vue(2.x) components for compare JSON data. Latest version: 3.0.0, last published: 5 years ago. Start using vue-json-compare in your project by running `npm i vue-json-compare`. There are 3 other projects in the npm registry using vue-json-compare.
      » npm install vue-json-compare
    
Published   Aug 20, 2020
Version   3.0.0
Author   alpaca
Top answer
1 of 4
8

Friends! I'm really sorry if I don't understand something, or explain question in wrong terms. All I wanna do is to compare the equality of two pieces of JSON-standardized data like this:

{"skip":0, "limit":7, "arr": [1682, 439, {"x":2, arr:[]}] }

{"skip":0, "limit":7, "arr": [1682, 450, "a", ["something"] }

I'm 100% sure there will be no functions, Date, null or undefined, etc. in these data. I want to say I don't want to compare JavaScript objects in the most general case (with complex prototypes, circular links and all this stuff). The prototype of these data will be Object. I'm also sure lots of skillful programmers have answered this question before me.

The main thing I'm missing is that I don't know how to explain my question correctly. Please feel free to edit my post.

My answer:

First way: Unefficient but reliable. You can modify a generic method like this so it does not waste time looking for functions and undefined. Please note that generic method iterates the objects three times (there are three for .. in loops inside)

Second way: Efficient but has one restriction. I've found JSON.stringify is extremely fast in node.js. The fastest solution that works is:

JSON.stringify(data1) == JSON.stringify(data2)

Very important note! As far as I know, neither JavaScript nor JSON don't matter the order of the object fields. However, if you compare strings made of objects, this will matter much. In my program the object fields are always created in the same order, so the code above works. I didn't search in the V8 documentation, but I think we can rely on the fields creation order. In other case, be aware of using this method.

In my concrete case the second way is 10 times more efficient then the first way.

2 of 4
4

I've done some benchmarking of the various techniques, with underscore coming out on top:

> node nodeCompare.js 

deep comparison res: true took: 418 (underscore)
hash comparison res: true took: 933
assert compare  res: true took: 2025
string compare  res: true took: 1679

Here is the source code:

var _ = require('underscore');

var assert = require('assert');

var crypto = require('crypto');

var large = require('./large.json');

var large2 = JSON.parse(JSON.stringify(large));

var t1 = new Date();
var hash = crypto.createHash('md5').update(JSON.stringify(large)).digest('hex');
var t2 = new Date();

var res = _.isEqual(large, large2);

var t3 = new Date();

var res2 = (hash == crypto.createHash('md5').update(JSON.stringify(large2)).digest('hex'));

var t4 = new Date();

assert.deepEqual(large, large2);

var t5 = new Date();

var res4 = JSON.stringify(large) === JSON.stringify(large2);

var t6 = new Date();

console.log("deep comparison res: "+res+" took: "+ (t3.getTime() - t2.getTime()));
console.log("hash comparison res: "+res2+" took: "+ (t4.getTime() - t3.getTime()));
console.log("assert compare  res: true took: "+ (t5.getTime() - t4.getTime()));
console.log("string compare  res: "+res4+" took: "+ (t6.getTime() - t5.getTime()));
🌐
GitHub
github.com › drkl151 › compare-json-translations
GitHub - drkl151/compare-json-translations: Npm which compares json files to each other and displays them in a table
This npm compares all .json files and allows the user to quickly find missing or duplicate values ​​in those files.
Author   drkl151
🌐
npm Trends
npmtrends.com › compare-json
compare-json | npm trends
npm trends · Compares two or more JSON files for missing object keys, useful for checking i18n language files. compare-json · Bytes is a JavaScript newsletter you'll actually enjoy reading. Delivered every Monday, for free.
🌐
npm
npmjs.com › package › json-schema-compare
json-schema-compare - npm
Compare json schemas smarter.. Latest version: 0.2.2, last published: 8 years ago. Start using json-schema-compare in your project by running `npm i json-schema-compare`. There are 8 other projects in the npm registry using json-schema-compare.
      » npm install json-schema-compare
    
Published   Oct 22, 2017
Version   0.2.2
Author   Martin Hansen
🌐
NPM Compare
npm-compare.com › deep-diff,json-diff,jsondiffpatch
deep-diff vs jsondiffpatch vs json-diff | JavaScript Object Comparison Libraries
Comprehensive comparison of deep-diff, jsondiffpatch, json-diff npm packages, including features, npm download trends, ecosystem, popularity, and performance.
🌐
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
npm.io › package › json-diff
Json-diff NPM | npm.io
% 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).