Binary serialization that gets out of your way.
Sia is a fast, compact binary serialization library with native implementations in TypeScript, Go, Python, and C++. No field tags, no type markers: just values and length prefixes. All four implementations produce the same bytes on the wire, so you can serialize in one language and deserialize in another.
| Language | Repo | Package | Install |
|---|---|---|---|
| TypeScript | ts-sia | @timeleap/sia |
npm install @timeleap/sia |
| Go | go-sia | github.com/TimeleapLabs/go-sia/v2 |
go get github.com/TimeleapLabs/go-sia/v2 |
| Python | py-sia | timeleap-sia |
pip install timeleap-sia |
| C++ | cpp-sia | CMake | FetchContent or add_subdirectory |
| Schema | sia-schema | @timeleap/sia-schema |
npm install -g @timeleap/sia-schema |
Define a User, serialize it, read it back:
TypeScript
import { Sia } from "@timeleap/sia";
const sia = new Sia();
sia.addString8("Alice").addUInt8(30).addBool(true);
sia.seek(0);
console.log(sia.readString8()); // "Alice"
console.log(sia.readUInt8()); // 30
console.log(sia.readBool()); // trueGo
import sia "github.com/TimeleapLabs/go-sia/v2/pkg"
s := sia.New()
s.AddString8("Alice").AddUInt8(30).AddBool(true)
s.Seek(0)
fmt.Println(s.ReadString8()) // "Alice"
fmt.Println(s.ReadUInt8()) // 30
fmt.Println(s.ReadBool()) // truePython
from sia import Sia
s = Sia()
s.add_string8("Alice").add_uint8(30).add_bool(True)
s.seek(0)
print(s.read_string8()) # "Alice"
print(s.read_uint8()) # 30
print(s.read_bool()) # TrueC++
#include <sia/sia.hpp>
auto s = sia::New();
s->AddString8("Alice");
s->AddUInt8(30);
s->AddBool(true);
s->Seek(0);
std::cout << s->ReadString8() << std::endl; // "Alice"
std::cout << s->ReadUInt8() << std::endl; // 30
std::cout << s->ReadBool() << std::endl; // true- 2-4x faster than JSON, MessagePack, and Protobuf in TypeScript benchmarks
- 14-77% smaller wire format: no field names, no type markers, just values and length prefixes
- Zero dependencies in every language: pure standard-library code, no native modules, no WASM
- Schema compiler: define types in
.siafiles, generate serializers for all four languages
Instead of writing addString8 / readString8 calls by hand, define your types once:
schema User {
name string8
age uint8
email string16
active bool
}
Then generate code for any target language:
sia compile user.sia -o user.ts
sia compile user.sia -o user.go
sia compile user.sia -o user.py
sia compile user.sia -o user.cppThe schema compiler is a Node.js CLI tool (@timeleap/sia-schema). The generated code is native to each target language with no Node.js dependency. See the sia-schema repo for details.
This repository contains the unified documentation site for all Sia implementations, built with Docus.
npm install
npm run devThe site starts at http://localhost:3000.
content/
index.md Landing page
docs/
0.index.md Introduction
1.installation.md Installation for all languages
2.quickstart.md Quick start guide
3.core/ Buffer management, serialization, deserialization
4.api/ API reference (integers, strings, byte arrays, arrays, booleans, bigint)
6.schema/ Schema compiler docs (syntax, code generation, plugins, VS Code)
7.guides/ Data types, memory management, performance
8.advanced/ Unsafe buffers, custom serialization, benchmarks
ISC