NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
npm · #2407 most downloaded on npm
A bson parser for node.js and the browser
Last release 3 days ago
15 Sep 2026
Release timing varies
gaps range from 2 weeks to 5 months
Nearly every release is documented
notes for 53 of 56 stable releases
111 versions withdrawn
withdrawn after publishing
15 years old
185 releases · first in 2011
…Timestamp(increment, timestamp) option has been deprecated.
The MongoDB Node.js team is pleased to announce version 4.5.0 of the bson module!
The Timestamp constructor can now be called with a more convenient object parameter: new Timestamp({ t: number, i: number }); the existing new Timestamp(increment, timestamp) option has been deprecated.
Furthermore, this minor version significantly improves deserialization performance for buffer inputs and corrects an issue with our ESM bundles resulting from a reference to global which does not exist in web environments.
We invite you to try the bson library immediately, and report any issues to the NODE project.
One column per quarter.
The MongoDB Node.js team is pleased to announce version 4.4.1 of the bson package!
The MongoDB Node.js team is pleased to announce version 4.4.1 of the bson package!
This patch addresses the bugs listed below. Most notably our EJSON API now correctly stringifies Infinity and NaN doubles in relaxed mode. Relaxed mode is intended for human readable JSON while non-relaxed or canonical mode can be used for data serialization since it will preserve the original BSON type. Double check you are using the correct format for your use case.
We invite you to try the bson library immediately, and report any issues to the NODE project.
The MongoDB Node.js team is pleased to announce version 4.4.0 of the bson module!
The MongoDB Node.js team is pleased to announce version 4.4.0 of the bson module!
This release of the BSON library brings some additional convenience to our Decimal128 and Long classes.
Users can now specify the construction of these types as shown below:
const longFromBigInt = new Long(23n)
const d128FromString = new Decimal128('4.23')
Here is the new API specification:
[new] Decimal128(string)[new] Long(string[, unsigned])[new] Long(bigint[, unsigned])Thanks so much to @addaleax to contributing a number of the fixes listed below! 🚀
__proto__ properties (#431) (f34cabc)We invite you to try the bson library immediately, and report any issues to the NODE project.
The MongoDB Node.js team is pleased to announce version 4.3.0 of the bson module!
The MongoDB Node.js team is pleased to announce version 4.3.0 of the bson module!
With this feature release we are introducing improved support for UUID usage in BSON. UUIDs in BSON are still a subset of Binary so there is a translation that must occur to use UUIDs in BSON documents.
For example:
// import { UUID, serialize, deserialize } from 'bson'
const { UUID, serialize, deserialize } = require('bson')
const myId = new UUID();
const bsonBuffer = serialize({ myId: myId.toBinary() })
const bsonResult = deserialize(bsonBuffer)
myId.equals(bsonResult.myId.toUUID()) // true!
Full API documentation for the new class will be available here soon after this release.
We invite you to try the bson library immediately, and report any issues to the NODE project. A special thanks to @steffenagger for his contribution to the library!
The MongoDB Node.js team is pleased to announce version 4.2.3 of the bson module!
The MongoDB Node.js team is pleased to announce version 4.2.3 of the bson module!
With this version, inspecting BSON objects produces the exact code to instantiate them.
<h2> Bug Fixes </h2> <ul> <li>[<a href='https://jira.mongodb.org/browse/NODE-2947'>NODE-2947</a>] - Inspection method for Binary does not yield same result when evaluated </li> <li>[<a href='https://jira.mongodb.org/browse/NODE-3064'>NODE-3064</a>] - Fix BSON type classes being called without new </li> <li>[<a href='https://jira.mongodb.org/browse/NODE-3069'>NODE-3069</a>] - Cannot use bson package in a webworker. </li> </ul>
We invite you to try the bson library immediately, and report any issues to the NODE project. Thanks very much to all the community members who contributed to this release!
The MongoDB Node.js team is pleased to announce version 4.2.2 of the bson module!
The MongoDB Node.js team is pleased to announce version 4.2.2 of the bson module!
This patch fixes a critical bug in the 4.2.1 release we recommend all users of 4.2.1 upgrade to this version immediately. There was an unintended dependency published on tslib without tslib being specified in our package.json.
This patch includes additional 'inspect' methods on each BSON type class that makes printing out values consistent and readable.
EJSON.stringifyWe invite you to try the bson library immediately, and report any issues to the NODE project. Thanks very much to all the community members who contributed to this release!
This version has a critical bug that prevents it from importing correctly. There was an unintended dependcy on tslib published without tslib being spe
This version has a critical bug that prevents it from importing correctly. There was an unintended dependcy on tslib published without tslib being specified in our package.json. A workaround is installing tslib manually but we highly recommend users of this version should update to v4.2.2 instead.
The MongoDB Node.js team is pleased to announce version 4.2.1 of the bson module!
This patch includes additional 'inspect' methods on each BSON type class that makes printing out values consistent and readable.
EJSON.stringifyWe invite you to try the bson library immediately, and report any issues to the NODE project. Thanks very much to all the community members who contributed to this release!
This had been unused for sometime and here we were able to remove this code improving bundle sizes but without any breaking changes.
The MongoDB Node.js team is pleased to announce version 4.2.0 of the bson module!
Before this release we have converted the codebase to Typescript and you can find our bundled type definitions in the release. Converting to Typescript gave us an opportunity to fine tune our build pipeline, you should expect proper web bundle support with sourcemaps. If you were to ever encounter an issue or just want to get insight into the inner workings of the BSON library these sourcemaps will allow you to debug the original source code that is in typescript.
If you’re curious about Typescript take a look here.
A primary reason for converting to typescript is the first in class developer experience the language offers. It enables us to communicate APIs more succinctly to you the user and for you the user to benefit from excellent autocompletion and code intellisence while working with the BSON library.
BigInt is a new primitive type added to the ECMAScript specification, with this release you can use these new Long helpers to serialize BigInt(s) to BSON.
class Long {
// ...
/**
* Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
* @param value - The number in question
* @param unsigned - Whether unsigned or not, defaults to signed
* @returns The corresponding Long value
*/
static fromBigInt(value: bigint, unsigned?: boolean): Long;
/** Converts the Long to a BigInt (arbitrary precision). */
toBigInt(): bigint;
// ...
}
It is important to note that BigInt supports arbitrary precision values while Long’s are clamped to maximum and minimum 64-bit integer values. We do have an investigation into supporting BigInt directly as well as helpers for Decimal128 interop but for now this is a great stepping stone to get started using BigInt in your code today!
A previous iteration of the ObjectId class utilized a Fowler–Noll–Vo hash function to generate a portion of the Id created on the client side. This had been unused for sometime and here we were able to remove this code improving bundle sizes but without any breaking changes.
We invite you to try the bson library immediately, and report any issues to the NODE project. Thanks very much to all the community members who contributed to this release!
<a name="4.1.0"></a>
<a name="4.0.4"></a>
Nothing published for this version
This patch release fixes a regression introduced in v2 of the module, preventing round tripping of the deprecated BSON symbol type. We don't expect an…
The MongoDB Node.js team is pleased to announce version 4.0.4 of the bson module!
This patch release fixes a regression introduced in v2 of the module, preventing round tripping of the deprecated BSON symbol type. We don't expect any users are actually using this value, but it is something used in internal testing of the driver and as such was deemed high priority to fix.
<h3> Bug </h3> <ul> <li>[<a href='https://jira.mongodb.org/browse/NODE-2518'>NODE-2518</a>] - BSON loses type information when automatically upgrading symbols to strings </li> </ul>
symbol to string if promoteValues is true (067a7ba)<a name="4.0.3"></a>
support Number object in Int32 and Double constructors
buffer: don't use deprecated Buffer constructors
ObjectID (ba98ccb), closes #303EJSON.stringify (9f43809), closes #303 #302 #303<a name="4.0.1"></a>
Please see the migration guide for detailed discussion of breaking changes in this release.
<a name="4.0.0"></a>
Please see the migration guide for detailed discussion of breaking changes in this release.
Number in relaxed mode (a767fa1)browser section needs to point to correct index (08337e3)_bsontypes to non-enumerable properties (16f5bf6)<a name="3.0.2"></a>
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
ObjectID: use FNV-1a hash for objectId
Nothing published for this version
Nothing published for this version
readme: clarify documentation about deserialize methods
binary: add type checking for buffer
deserializeStream: allow multiple documents to be deserialized (6fc5984), closes #244
regexp: properly construct new BSONRegExp when constructor called without new
<a name="2.0.3"></a>
serialization: support arbitrary sizes for the internal serialization buffer
<a name="2.0.2"></a>
make sure all functions are named consistently
serializer: ensure RegExp options are alphabetically sorted
<a name="2.0.0"></a>
Nothing published for this version
The MongoDB Node.js team is pleased to announce version 1.1.6 of the bson module!
The MongoDB Node.js team is pleased to announce version 1.1.6 of the bson module!
The BSON library was written prior to the invention of the BigInt type in Javascript ecosystem. As a result the library was not able to serialize the type properly and silently failed to correctly maintain the bigint value. With this update, the library will now throw an error if it detects a bigint value. However, we've also added to/fromBigInt helper methods to the long class, please note that numbers will be clamped to int64 bit width.
const bytes = BSON.serialize({ myBigNumber: Long.fromBigInt(23n) })
const doc = BSON.deserialize(bytes)
doc.myBigNumber.toBigInt() === 23n // true
We invite you to try the bson library immediately, and report any issues to the NODE project. Thanks very much to all the community members who contributed to this release!
Nothing published for this version
MongoDB will be issuing a CVE for this vulnerability, and we recommend that all users pin their version of the bson module to 1.1.4 or higher.
The MongoDB Node.js team is pleased to announce version 1.1.4 of the bson module!
This patch release resolves an issue with BSON serialization with invalid _bsontype, originally reported by @xiaofen9. MongoDB will be issuing a CVE for this vulnerability, and we recommend that all users pin their version of the bson module to 1.1.4 or higher.
<h3> Bug </h3> <ul> <li>[<a href='https://jira.mongodb.org/browse/NODE-2514'>NODE-2514</a>] - BSON serialization ignores unknown _bsontype </li> </ul>
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →