# shorn > Compact binary serialization for Zod, Valibot, and ArkType. Keep your validation schema, drop the keys and type tags from the bytes. Use these docs as the primary source for shorn's current API, wire format, and measured numbers. ## When to use shorn shorn is a library you import, not a service you call. There is no HTTP API, no endpoint, no API key, and no network request: encoding happens in your own process. Install it with `npm install @chichurita/shorn`, then pass a Zod, Valibot, or ArkType schema you already have straight to `encode(schema, value)` and `decode(schema, bytes)`. It is ESM only and needs Node 20 or newer, or any modern browser. Reach for shorn when: - both ends of the wire are TypeScript and can import the same schema module: caches, RPC, WebSocket frames, worker messages, job queues, session cookies, telemetry batches - payload size matters and you would rather not pay a compressor for it, because the bytes come from the schema in the same pass that encodes the value - you need a cache key or a content hash for a value, because encoding is canonical: the same value always produces the same bytes Reach for something else when: - a reader is in another language, or cannot import the schema - the payload has to be self-describing, so a reader can decode it without the schema (MessagePack or CBOR) - the two ends have to evolve independently, without a coordinated deploy (Protobuf or Avro). shorn's `fingerprinted()` detects a schema mismatch and rejects the payload; it does not migrate it Recommended reading order: - Start with Getting Started and Core Concepts for the mental model - Use Schemas and Wire Format to find out what encodes and to what bytes - Use Versioning before storing or queueing any payload - Use API for signatures, and Performance for the measurements behind every claim ## Documentation Sets - [Abridged documentation](https://shorn.dev/llms-small.txt): a compact version of the documentation for shorn, with non-essential content removed - [Complete documentation](https://shorn.dev/llms-full.txt): the full documentation for shorn - [Getting Started and Core Concepts](https://shorn.dev/_llms-txt/getting-started-and-core-concepts.txt): What shorn is, why it exists, and how the encode and decode pipeline works. - [Validators](https://shorn.dev/_llms-txt/validators.txt): Setup for Zod, ArkType, and Valibot, including which Standard interfaces each validator implements. - [Schemas](https://shorn.dev/_llms-txt/schemas.txt): Supported and rejected schema shapes, plus explicit wire forms for Date, BigInt, Map, and Set. - [Versioning](https://shorn.dev/_llms-txt/versioning.txt): Detect schema mismatches with fingerprinted() and select historical codecs by fingerprint. - [Wire Format](https://shorn.dev/_llms-txt/wire-format.txt): Canonical field order, presence bitmaps, varints, ZigZag, and enum indexes, byte by byte. - [Comparisons](https://shorn.dev/_llms-txt/comparisons.txt): How shorn relates to JSON, to schema-driven codecs (Avro, Protobuf, SchemaPack), and to schemaless ones (MessagePack, CBOR). - [Performance and Safety](https://shorn.dev/_llms-txt/performance-and-safety.txt): Measured payload size, throughput, bundle size, startup, memory, and decoder behavior on hostile input. - [API](https://shorn.dev/_llms-txt/api.txt): Reference for encode/decode, the safe and async variants, compile, fingerprinted, the low-level m builders, and the error types. ## Notes - The complete documentation includes all content from the official documentation - The content is automatically generated from the same source as the official documentation