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 install json-diff-ts
Videos
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.
You can have a look at json diff wrapper here
It has also demo page.You can use this wrapper.
» npm install json-diff-kit
» npm install @types/json-diff
Built a JSON/YAML comparison tool this weekend as a React learning project.
Tech choices:
React 18 with hooks (useState, useEffect)
TypeScript for type safety
Vite for blazing fast dev experience
Tailwind CSS for styling
Deployed on Vercel (auto-deployment from GitHub)
What it does: Compare configuration files side-by-side with color-coded differences.
Try it: https://diff-master.vercel.app/
React patterns used:
Component composition (ComparisonArea, ResultsSection, Header)
Custom hooks for state management
TypeScript interfaces for type safety
Responsive design with Tailwind
Interesting challenges solved:
Deep object comparison algorithm
Real-time format detection (JSON vs YAML)
Efficient diff calculation for large files
Markdown export functionality
Built with bolt.diy (AI-assisted coding) which helped me:
Scaffold the project structure quickly
Generate TypeScript types
Debug TypeScript compilation errors
Deploy to Vercel
What would you improve from a React architecture perspective?
https://imgur.com/a/Ye6WFDQ
» npm install json-diff