Introduction
Schema-aware, high-performance JSON serialization for TypeScript
fatline is a schema-aware, high-performance JSON serialization library for TypeScript. Named after the FTL communication devices in Dan Simmons' Hyperion Cantos, it transmits your data structures across the wire—intact, minimal, and fast.
Your Types, Preserved
import { serialize, deserialize } from 'fatline'
const data = {
user: { createdAt: new Date(), roles: new Set(['admin']) }
}
const json = serialize(data)
const back = deserialize(json)
// back.user.createdAt instanceof Date ✓
// back.user.roles instanceof Set ✓No setup. No registration. It just works.
Schema-Aware Serialization
When you define schemas with Zod, Valibot, or ArkType, fatline uses them for type-safe encoding and validation:
import { createCodec } from 'fatline/codec'
import { z } from 'zod'
const UserCodec = createCodec(z.object({
id: z.string(),
createdAt: z.date(),
tags: z.set(z.string()),
}))
const user = UserCodec.decode(json)
// ^? { id: string, createdAt: Date, tags: Set<string> }Each codec has a content-based hash. When schemas match between client and server, fatline can eliminate type metadata from the wire entirely.
Framework Integration
| Framework | Import | Docs |
|---|---|---|
| tRPC | import { transformer } from 'fatline/trpc' | → |
| Hono | import { fatlineMiddleware } from 'fatline/hono' | → |
| TanStack Query | { serializeData: serialize } | → |
| Next.js | import { serialize, deserialize } from 'fatline' | → |
| oRPC | import { FatlineSerializer } from 'fatline/orpc' | — |
Errors That Help
serialize(data)
// FatlineError: Cannot serialize value at `user.settings.theme`
//
// Found: [Function: getTheme]
//
// Functions cannot be serialized. You can:
// 1. Exclude it: serialize(data, { exclude: ['user.settings.theme'] })
// 2. Transform it first
// 3. Register a custom type handlerProgressive Disclosure
// Level 1: Just works
import { serialize, deserialize } from 'fatline'
// Level 2: Schema-aware (faster, type-safe)
import { createCodec } from 'fatline/codec'
// Level 3: Framework adapters
import { transformer } from 'fatline/trpc'
// Level 4: Advanced
import { registerType, configure } from 'fatline'