npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

big-json-diff

v0.7.0

Published

JSON diff with support for big numbers

Readme

big-json-diff

Build Status

This module is a fork of json-diff 0.5.3. It generally offers all functions of the original module but also extends it by offering an option for big number support.

Use the following command to install this module locally:

$ npm install big-json-diff

If you prefer a global installation, you of course can also use this command instead:

$ npm install -g big-json-diff

When adding the option --bigNumberSupport or its shortcut -b while running big-json-diff from console, it is possible to get proper diffs for JSON files that contain numbers of any size as this module then uses a big number JSON parser internally to build objects from JSON files.

If you have installed big-json-diff globally, just run one of the following commands from console to create a diff for JSON files that contain big numbers.

$ big-json-diff -b <path-to-old-file> <path-to-new-file>

or

$ big-json-diff --bigNumberSupport <path-to-old-file> <path-to-new-file>

Of course, in case you have installed big-json-diff locally and would like to execute it via console, navigate to the installation root directory and use one of the following commands for getting diffs that also consider big numbers.

$ node_modules/.bin/big-json-diff -b <path-to-old-file> <path-to-new-file>

or

$ node_modules/.bin/big-json-diff --bigNumberSupport <path-to-old-file> <path-to-new-file>

If you need to call the crorresponding function programatically, you first have to ensure all big numbers are already converted to bignumber.js objects. Then simply run the function diffString() and add the option { bigNumberSupport: true } to the function as displayed in the following example.

const BigNumber = require('bignumber.js');
const bigJsonDiff = require('big-json-diff')

const oldBigNumber = BigNumber('3e+5000')

const newBigNumber = BigNumber('12345678901234567890')

console.log(bigJsonDiff.diffString(oldBigNumber, newBigNumber, { bigNumberSupport: true })) 
// -3e+5000
// +12345678901234567890

Note: Since this module internally works with bignumber.js objects, it cannot be guaranteed for big numbers that they will be represented in the same way as transferred to big-json-diff. This means, big-json-diff can represent numbers written in scientific notation as decimal numbers and vice versa. However, the representation does not have any effect on the actual meaning of the result, such that big-json-diff should always be able to return all diffs.

Of course, it is also possible to add the option { bigNumberSupport: true } to the function diff(). Also in this case bigNumber.js objects will be recognized as such, which is illustrated in the next example:

const BigNumber = require('bignumber.js');
const bigJsonDiff = require('big-json-diff')

const oldBigNumber = BigNumber('3e+5000')

const newBigNumber = BigNumber('12345678901234567890')

console.log(bigJsonDiff.diff(oldBigNumber, newBigNumber, { bigNumberSupport: true })) 
// { __old: BigNumber { s: 1, e: 5000, c: [ 300 ] },
//  __new: BigNumber { s: 1, e: 19, c: [ 123456, 78901234567890 ] } }

Further features that are already supported by json-diff 0.5.3 can be seen in the corresponding README.