# json-with-bigint

> JS library that allows you to easily serialize and deserialize data with BigInt values

Latest version **3.5.12** (published 2026-08-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install json-with-bigint
pnpm add json-with-bigint
yarn add json-with-bigint
bun add json-with-bigint
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.5.12 |
| Published | 2026-08-17 |
| First published | 2023-03-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 0 |
| Unpacked size | 71.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Ivan Korolenko |
| Maintainers | ivankorolenko |
| Keywords | JSON, BigInt, js, ts, library |

## Links

- npm: https://www.npmjs.com/package/json-with-bigint
- Repository: https://github.com/Ivan-Korolenko/json-with-bigint
- Homepage: https://github.com/Ivan-Korolenko/json-with-bigint#readme
- Issues: https://github.com/Ivan-Korolenko/json-with-bigint/issues
- npm.io page: https://npm.io/package/json-with-bigint

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 3.5.12 (latest) — 2026-08-17
- 3.5.11 — 2026-08-14
- 3.5.10 — 2026-07-11
- 3.5.9 — 2026-07-11
- 3.5.8 — 2026-03-19
- 3.5.7 — 2026-02-28
- 3.5.6 — 2026-02-28
- 3.5.3 — 2026-01-13
- 3.5.2 — 2025-12-21
- 3.5.1 — 2025-12-19
- 3.5.0 — 2025-12-18
- 3.4.4 — 2025-04-15
- 3.3.4 — 2025-04-14
- 3.3.3 — 2025-04-14
- 3.3.2 — 2025-03-28
- … 18 more at https://npm.io/package/json-with-bigint/versions

## README

# JSON with BigInt

JS library that allows you to easily serialize and deserialize data with BigInt values

## Why would I need json-with-bigint?

3 reasons:

1. You need to convert some data to/from JSON and it includes BigInt values
2. Native JSON.stringify() and JSON.parse() methods in JS can't work with BigInt
3. Other libraries and pieces of code that you'll find either can't solve this problem while supporting consistent round-trip operations (meaning, you will not get the same BigInt values if you serialize and then deserialize them) or requires you to specify which properties in JSON include BigInt values, or to change your JSON or the way you want to work with your data

## json-with-bigint advantages

✔️ Supports consistent round-trip operations with JSON

```
const data = { bigNumber: 9007199254740992n };
JSONStringify(data) // '{"bigNumber":9007199254740992}'
JSONParse(JSONStringify(data)).bigNumber === 9007199254740992n // true
```

✔️ No need to specify which properties in JSON include BigInt values. Library will find them itself

✔️ No need to change your JSON or the way you want to work with your data

✔️ You don't have to memorize this library's API, you already know it. Just skip the dot, and that's it (`JSONParse()`, `JSONStringify()`)

✔️ Parsed big number values are just regular BigInt. Parses and stringifies all other values other than big numbers the same way as native JSON methods in JS do. Signatures match too. You can just replace every `JSON.parse()` and `JSON.strinfigy()` in your project with `JSONParse()` and `JSONStringify()`, and it will work

✔️ Supports modern features (context.source, rawJSON, etc.)

✔️ If the browser doesn't support the reviver functionality in `JSON.parse`, this library will safely fall back to the implementation that doesn't need it and will continue to work.

✔️ Correctly parses float numbers and negative numbers

✔️ Correctly parses pretty printed JSON (formatted with newline and whitespace characters)

✔️ Correctly parses deep-nested (5000 levels+) JSONs

✔️ Does not contaminate your global space (unlike monkey-patching solution)

✔️ Isomorphic (it can run in both the browser and Node.js with the same code)

✔️ Can be used in both JavaScript and TypeScript projects (.d.ts file included)

✔️ Can be used as both ESM and CommonJS module

✔️ Actively supported

✔️ Size: 2676 bytes (minified and gzipped)

✔️ No dependencies. Even the dev ones

✔️ Extensively covered by tests

## Getting Started

This library has no default export. [Why it's a good thing](https://humanwhocodes.com/blog/2019/01/stop-using-default-exports-javascript-module/)

### NPM

Add this library to your project using NPM

```
npm i json-with-bigint
```

and use it

```
import { JSONParse, JSONStringify } from 'json-with-bigint';

const userData = {
  someBigNumber: 9007199254740992n
};

localStorage.setItem('userData', JSONStringify(userData));

const restoredUserData = JSONParse(localStorage.getItem('userData') || '');
```

### CDN

Add this code to your HTML

```
<script src="https://cdn.jsdelivr.net/npm/json-with-bigint/json-with-bigint.min.js"></script>
```

and use it

```
<script>
  const userData = {
    someBigNumber: 9007199254740992n
  };

  localStorage.setItem('userData', JSONStringify(userData));

  const restoredUserData = JSONParse(localStorage.getItem('userData') || '');
</script>
```

### Manually

Download json-with-bigint.min.js from this repository to your project's folder and use it

```
<script src="./json-with-bigint.min.js"></script>
<script>
  const userData = {
    someBigNumber: 9007199254740992n
  };

  localStorage.setItem('userData', JSONStringify(userData));

  const restoredUserData = JSONParse(localStorage.getItem('userData') || '');
</script>
```

## How to use

`JSONParse` - works just like [native JSON.parse](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse), but supports BigInt

`JSONStringify` - works just like [native JSON.stringify](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify), but supports BigInt

Examples:

- `JSONParse('{"someBigNumber":9007199254740992}')`
- `JSONStringify({
someBigNumber: 9007199254740992n
})`

---
_Source: https://npm.io/package/json-with-bigint · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
