Introduction
shorn encodes data with the schema your project already uses. It reads Standard Schema for validation and Standard JSON Schema for structure. Field names and type tags stay in the schema instead of being repeated in every payload.
import { z } from "zod";import { decode, encode } from "shorn";
const Person = z.object({ name: z.string(), age: z.int().nonnegative(), sex: z.enum(["M", "F", "X"]),});
const bytes = encode(Person, person); // 8 bytesconst decoded = decode(Person, bytes);The same value is 35 bytes of minified JSON.
What you get
Section titled “What you get”- No shorn schema language. No IDL, CLI, codegen, or compiler plugin.
- Canonical bytes. Equivalent Zod, Valibot, and ArkType schemas encode identically.
- Validation both ways. Your library runs on encode and again on decode.
- 5.39 KB gzip runtime, the smallest codec in the measured comparison, tree-shaken per feature.
- MIT licensed.
What you do not get
Section titled “What you do not get”shorn is an experimental alpha with important limits:
- No schema evolution. Only the schema that wrote a payload can decode it.
fingerprinted()detects a mismatch; nothing resolves one. - No streaming, random access, or zero-copy views.
- No cross-language decoder. TypeScript and JavaScript only.
- Not the fastest. Avro encodes faster. msgpackr shared records decode nested and batch data faster. shorn beats JSON in both directions on every measured fixture; see Throughput.
- Not confidential. Encrypt the bytes when secrecy matters.
Where next
Section titled “Where next”| To | Read |
|---|---|
| Understand the pitch | Why shorn? |
| Get running | Installation, Quick Start |
| Know what encodes | Supported Types |
| Store or queue payloads | Fingerprinting — not optional |
| See the bytes | Byte Layout |