https://github.com/omgaz/diffler
A recursive JSON comparison script for humans
https://github.com/omgaz/diffler
compare hacktoberfest javascript jsdiff json json-objects
Last synced: 14 days ago
JSON representation
A recursive JSON comparison script for humans
- Host: GitHub
- URL: https://github.com/omgaz/diffler
- Owner: omgaz
- License: mit
- Created: 2012-05-10T10:10:15.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2025-11-15T10:34:17.000Z (6 months ago)
- Last Synced: 2026-03-15T12:14:43.005Z (about 2 months ago)
- Topics: compare, hacktoberfest, javascript, jsdiff, json, json-objects
- Language: JavaScript
- Homepage:
- Size: 450 KB
- Stars: 18
- Watchers: 1
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
diffler
A recursive JSON comparison script for humans
## Motivation
To compare JSON objects containing asset metadata for a digital library. Upon change of any metadata, we'd store these changes as an audit trail and email asset stakeholders for review and approval of the changes.
## Usage
[](https://www.npmjs.com/package/diffler)
```bash
npm install diffler
```
### Params
`original` and `updated` are two JSON objects for comparison.
### Return
If same: returns `{}` _(empty object)_
If different: A JSON object with preserved path structure. The resulting values will be an object with `from` and `to` fields.
### Example
#### ESM
```ts
import diffler from 'diffler';
const before = { name: 'omgaz', location: 'London' };
const after = { name: 'omgaz', location: 'Melbourne' };
const difference = diffler(before, after);
console.log(difference); // { location: { from: 'London', to: 'Melbourne' } }
```
#### CommonJS
```js
const diffler = require('diffler');
const before = { name: 'omgaz', location: 'London' };
const after = { name: 'omgaz', location: 'Melbourne' };
const difference = diffler(before, after);
console.log(difference); // { location: { from: 'London', to: 'Melbourne' } }
```
## Development
Requires Node 18+.
```bash
npm install
npm test
npm run build
```
### Scripts
| Command | Description |
| --------------------- | ----------------------------- |
| `npm test` | Run tests with Vitest |
| `npm run test:terse` | Run tests with minimal output |
| `npm run test:watch` | Run tests in watch mode |
| `npm run lint` | Check with Biome |
| `npm run lint:fix` | Auto-fix with Biome |
| `npm run check-types` | TypeScript type checking |
| `npm run build` | Build with Vite |
| `npm run bench` | Run performance benchmark |