Grounds
TypeScript implementation of Relish, a compact binary serialization format.
What is Relish?
Relish is a Type-Length-Value (TLV) encoding format designed by Alex Gaynor. It provides:
- Compact binary representation - smaller than JSON, competitive with Protocol Buffers
- Self-describing format - can decode without schema (for debugging)
- Schema-driven usage - type-safe encoding with TypeScript schemas
- Streaming support - encode and decode incrementally
For the complete format specification, see the Relish Spec.
Packages
Grounds provides three packages:
- @grounds/core - Low-level T[L]V encoding and decoding
- @grounds/schema - TypeBox-based schema definitions with codecs
- @grounds/stream - Streaming encode/decode utilities
Quick Example
import { RStruct, RString, RU32, field, createCodec } from "@grounds/schema";
// Define a schema
const UserSchema = RStruct({
name: field(0, RString()),
age: field(1, RU32()),
});
// Create a codec
const codec = createCodec(UserSchema);
// Encode
codec.encode({ name: "Alice", age: 30 }).match(
(bytes) => console.log("Encoded:", bytes.length, "bytes"),
(err) => console.error("Failed:", err.message),
);
Getting Started
New to Grounds? Start with Installation to set up your project.
Learn More
- Relish announcement blog post - Background and design rationale
- Relish specification - Wire format details
- Relish reference implementation - Rust implementation