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

smolcanon

v0.2.1

Published

Tiny JS objects canonicalization for hashing

Downloads

1,267

Readme

Smol Canon

Tiny JS values canonicalization for hashing.

It uses a simple serialization algorithm, generating a consistent string representation of JS values. It is built to use with Smol xxHash.

It is tiny and efficient. It is just 185B and 30%+ faster than other stable serialization libraries.

Unlike alternatives, it is focused on hashing and doesn't produce valid JSON, making it more efficient, and also supports more value types, i.e., undefined.

It features dual CJS/ESM support and built-in TypeScript definitions.

Installation

The package is available on npm:

npm install smolcanon

Usage

Pass any JS value to the canonize function to get its string representation:

import { canonize } from "smolcanon";

const canon = canonize({ foo: "bar", baz: "qux" });
// => '{foo:"bar";baz:"qux"}'

You can use it with Smol xxHash to produce consistent hashes for your data:

import { canonize } from "smolcanon";
import { xxh32 } from "smolxxh";

const canon = canonize({ foo: "bar", baz: "qux" });
const hash = xxh32(Buffer.from(canon, "utf8")).toString(16);
//=> "ed4e5029"

Benchmark

The benchmark shows that Smol Canon is significantly faster than other popular libraries for canonicalizing JavaScript values:

canonicalize:
  4 197 ops/s, ±0.28%   | 43.59% slower

json-canon:
  5 171 ops/s, ±2.11%   | 30.5% slower

fast-json-stable-stringify:
  4 548 ops/s, ±2.32%   | 38.87% slower

fast-safe-stringify:
  5 310 ops/s, ±2.30%   | 28.63% slower

fast-stable-stringify:
  4 973 ops/s, ±1.56%   | 33.16% slower

json-stable-stringify:
  3 648 ops/s, ±1.93%   | 50.97% slower

json-stringify-deterministic:
  3 054 ops/s, ±1.80%   | slowest, 58.95% slower

safe-stable-stringify:
  5 345 ops/s, ±2.17%   | 28.16% slower

smolcanon:
  7 440 ops/s, ±1.68%   | fastest

Changelog

See the changelog.

License

MIT © Sasha Koss