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

@chichurita/shorn

v0.7.3

Published

Binary serialization for the Zod, Valibot, or ArkType schema you already have

Readme

Installation

npm install @chichurita/shorn zod

Works in Node 20 or newer, Bun, Deno, browsers, and workers.

Encode a value

import { z } from "zod";
import { decode, encode } from "@chichurita/shorn";

const Person = z.object({
  name: z.string(),
  age: z.int().nonnegative(),
  sex: z.enum(["M", "F", "X"]),
});

const person = { name: "Grace", age: 45, sex: "F" } as const;

const bytes = encode(Person, person); // Uint8Array(8)
const back = decode(Person, bytes);   // typed and validated

shorn runs your validator before it writes the bytes, and again after it reads them back. The same schema written in Zod, Valibot, or ArkType produces the same bytes.

Where the bytes go

JSON spends most of its bytes on things both sides already know: field names, quotes, brackets, and commas. Your schema carries all of that, so shorn leaves it out and writes only the values. An enum member becomes a small index instead of a string. The picture above shows the result, and how it works walks through the eight bytes one at a time.

Store and queue safely

A bare payload does not say which schema wrote it. If the bytes will sit in a database, a queue, or a file, or cross a deployment boundary, add a fingerprint so that a mismatch is caught instead of decoded into a wrong value:

import { compile, fingerprinted } from "@chichurita/shorn";

const PersonWire = fingerprinted(compile(Person), { bytes: 4 });

const bytes = PersonWire.encode(person); // 4-byte fingerprint + payload
PersonWire.decode(bytes);                // rejects a different wire shape

Use another validator

Zod 4.2 or newer and ArkType 2.1.28 or newer work as they are: pass the schema. Valibot 1.x keeps its JSON Schema conversion in a separate package, so pass toStandardJsonSchema(schema) as the last argument. Under the hood, shorn reads validation through Standard Schema and structure through Standard JSON Schema.

Valibot's wrapper takes no options, so for Date, bigint, Map and Set use the raw converter together with valibotOverride:

import { toJsonSchema } from "@valibot/to-json-schema";
import { compile, valibotOverride } from "@chichurita/shorn";

const structure = toJsonSchema(schema, { overrideSchema: valibotOverride(toJsonSchema) });
const codec = compile(schema, structure);

Scope

Strings, booleans, integers, floats, literals, enums, nullable values, arrays, tuples, records, recursive schemas, z.any(), and objects, closed or open, with optional fields. Unions need a literal tag in every branch, or branches that share no JSON type. Date, bigint, Map, and Set are supported natively.

Not supported: overlapping unions, streaming, and schema migration. undefined, symbols, RegExp, and class instances have no wire form, so convert those first.

Against JSON bytes, encoding is up to 6.7× faster and decoding up to 13.0×, with no compressor involved. The m API is 6.45 KB gzip; compile with validation is 11.52 KB.

Documentation

Getting started, API reference, byte layout, supported types, rejected shapes, fingerprinting, performance.

MIT licensed.