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

jsonpack

v2.0.0

Published

A compression algorithm for JSON

Downloads

1,128,407

Readme

jsonpack

Test npm

A URL-safe JSON serializer. Produces compact ASCII output usable directly in URLs and localStorage — no base64, no binary, no extra encoding step.

Installation

npm install jsonpack

Usage

CommonJS

const { pack, unpack } = require('jsonpack');

ESM

import { pack, unpack } from 'jsonpack';

Example

const { pack, unpack } = require('jsonpack');

const data = {
    type: 'FeatureCollection',
    features: [
        { type: 'Feature', geometry: { type: 'Point', coordinates: [-73.98, 40.74] }, properties: { name: 'A' } },
        { type: 'Feature', geometry: { type: 'Point', coordinates: [-73.99, 40.75] }, properties: { name: 'B' } },
        // ... hundreds more
    ]
};

const packed = pack(data);
// repeated keys like "type", "Feature", "geometry", "Point", "coordinates"
// are stored once in a dictionary and referenced by index

const restored = unpack(packed);

API

pack(json, options?)

Serializes a JSON value into a compact URL-safe string.

  • json — any JSON-serializable value, or a JSON string
  • options.verbose — log each step to console (default: false)
  • options.debug — return internal representation instead of string (default: false)

Date objects are preserved: unpack(pack(date)) returns a Date instance, not a string.

Returns a string.

unpack(packed, options?)

Restores the original value from a packed string.

  • packed — string produced by pack()
  • options.verbose — log each step to console (default: false)

Returns the original value.


Why jsonpack

The standard way to embed JSON in a URL or localStorage is:

encodeURIComponent(JSON.stringify(data))

It works, but it expands your data — {, ", : become %7B, %22, %3A. A typical API response grows to 140–170% of its original size.

The alternative with the best compression, lz-string, shrinks data dramatically but decodes 4–6× slower.

jsonpack sits in between: < 7 KB minified, zero dependencies (no transitive dependencies either).

Benchmark

Measured across 8 real-world datasets (GeoJSON, e-commerce, API responses, deeply nested structures):

URL-safe JSON serializers: compression vs speed

| | encodeURI(JSON) | jsonpack | lz-string (URI) | |---|:---:|:---:|:---:| | Avg output size | 152% of original | 68% of original | 39% of original | | Avg unpack speed | 262 MB/s | 171 MB/s | 41 MB/s | | Zero dependencies | ✓ | ✓ | ✓ | | URL-safe output | ✓ | ✓ | ✓ |

Compression by dataset

Compression ratio by dataset

Unpack speed by dataset

Unpack speed by dataset

Full benchmark methodology and raw results: rgcl/jsonpack-benchmark

When to use jsonpack

Use jsonpack when:

  • You need to store JSON in a URL query string or localStorage
  • Output size matters (jsonpack produces ~55% less data than encodeURIComponent)
  • Fast decoding matters (jsonpack decodes 4× faster than lz-string)
  • You can't afford to grow your bundle

Use lz-string instead when output size is the only constraint and decoding speed doesn't matter.

Use encodeURIComponent when the data is small, changes rarely, or you want zero abstraction.

How it works

jsonpack builds a dictionary of all unique values (strings, integers, floats, dates) in the JSON and replaces them with base-36 indices. The result is a flat, ASCII-only string. Repeated keys and values — common in structured data like API responses and GeoJSON — are stored once and referenced everywhere.

Date objects are stored as ISO 8601 strings in the dictionary and marked with a special token in the structure, so unpack can restore them as Date instances. This is one area where jsonpack goes beyond what JSON.parse(JSON.stringify()) offers natively.


Notes

  • Pack and unpack are synchronous. For large payloads in a browser, run them in a Web Worker.
  • Requires Node.js ≥ 14.
  • The packed format is not binary-compatible with other JSON compression libraries.

Licence

MIT © 2013 Rodrigo González, SASUD