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 🙏

© 2026 – Pkg Stats / Ryan Hefner

binary-serde

v0.1.3

Published

Binary Javascript serializer/deserializer based on MessagePack

Readme

binary-serde

Binary Javascript serializer/deserializer based on MessagePack.

binary-serde has no dependencies, and uses TypedArrays internally that makes it work interchangeably both in Node.js and in browser.

Important! This is NOT a full MessagePack implementation. The main motivation backing binary-serde is replacement of JSON.stringify/parse which cause weird problems in some scenarios (e.g., serialization/deserialization of Redux state in SSR React applications).

Implementation Details and Limitations

binary-serde has the following limitations:

  • Maximum length of a stirng in UTF-8 bytes is (2^16 - 1).

  • Maximum length of an array is (2^16 - 1).

  • Maximum number of top-level properties of an object is (2^16 - 1).

  • Value undefined is serialized into value null.

Floating point numbers

binary-serde uses float 64 format for all floating point numbers. float 32 format is not implemented.

Dates

While encoding, binary-serde converts Date objects into strings using Date.prototype.toISOString(). On decode, these strings remain strings in ISO format.

MessgePack Extensions

Extensions are not implemented.

Installation

$ npm install --save binary-serde

Usage Examples

Node.js

const {
  encode,
  decode,
  bufferToString,
  stringToBuffer
} = require('binary-serde');

const data = {/* */};

const encodedBinData = encode(data);

// encodedBinData is an Uint8Array. Do whatever you want with it.
// E.g., serialize it into a HEX-encoded string using bufferToString utility
// provided by binary-serde

const encodedStr = bufferToString(encodedBinData);

// Then you might want to deserialize this string back into Uint8Array.
// Use stringToBuffer utility provided by binary-serde

const decodedBinData = stringToBuffer(encodedStr);

// Finaly decode this Uint8Array back into JS value
const decodedData = decode(decodedBinData);

Using in Browser

If you do care about size of javascript bundle served to the client and use only a part of binary-serde's functionality in your client code, binary-serde provides atomic exports of its functions:

import encode from 'binary-serde/browser/encode';
import decode from 'binary-serde/browser/decode';
import bufferToString from 'binary-serde/browser/buffer-to-string';
import stringToBuffer from 'binary-serde/browser/string-to-buffer';

Note. binary-serde exposes CommonJS modules. Hence, you'll need a build tool, such as Webpack, to use binary-serde in browser code.

API Reference

encode(data)

Encode any JSON.stringify-able javascript value into an Uint8Array.

data {Any} - any JSON.stringify-able javascript value.

Returns {Uint8Array}.

decode(buff)

Decode Uint8Array back into javascript value.

buff {Uint8Array} - Binary data encoded with binary-serde.

Returns {Any} - decoded javascript value.

bufferToString(buff)

Utility function to serialize an Uint8Array into a HEX-encoded string.

buff {Uint8Array}

Returns {String}.

stringToBuffer(str)

Utility function to deserialize a HEX-encoded string into an Uint8Array.

str {String} - HEX-encoded string.

Returns {Uint8Array}.