1 unstable release
| 0.1.0 | Feb 6, 2026 |
|---|
#1328 in Command line utilities
22KB
276 lines
๐ฏ ZON
Stop Parsing. Start Reading.
A Zero-Copy, Schema-Less Binary Format
6.2ร Faster than JSON
Quick Start โข Why ZON? โข Benchmarks โข Documentation
โก ZON in 30 Seconds
ZON removes the "JSON tax."
Your data becomes a high-speed binary format that browsers and servers can read instantlyโwithout the CPU overhead of parsing.
import { ZonReader } from '@zon-lib/zon';
async function loadData() {
const res = await fetch('https://api.example.com/stats.zon');
const buffer = new Uint8Array(await res.arrayBuffer());
// โจ wrap the buffer โ no parsing happens here
const stats = new ZonReader(buffer);
// ๐ read data at o(1) speed
console.log(stats.readU32(8));
}
The Result? 6.2ร faster data access with zero parsing overhead.
๐ฏ Quick Install
# node.js / web (wasm)
npm install @zon-lib/zon
# rust (systems)
cargo add zon-lib
# cli inspector
cargo install zon-inspector
๐ก The Philosophy
Modern applications suffer from a "Parsing Tax." Whether JSON or Protobuf, your CPU wastes massive cycles translating text into memory before you can even use it.
ZON (Zero-Overhead Notation) eliminates this translation step.
The binary format on disk is the exact same layout your CPU requires in memory.
Core Principles:
- ๐ฏ Zero-Copy Access โ We don't parse. We map directly to memory.
- ๐ Schema-Less โ No
.protofiles. No code generation. - ๐ Universal โ Native speed in Rust. Instant bridging in WASM.
๐ Why for Web?
Lower Battery Drain โ Less CPU usage means better battery life for mobile users
Zero UI Lag โ Large datasets (maps, 3D models, telemetry) load without freezing
Edge Ready โ Minimal memory footprint for Vercel Functions and Cloudflare Workers
๐ Benchmarks
ZON vs. JSON (Accessing a composite Player struct)
| Format | Mean Access Time | Throughput | Speedup |
|---|---|---|---|
| JSON | ~117.43 ns | ~8.5 M ops/s | 1ร |
| ZON | ~18.83 ns | ~53.1 M ops/s | ๐ 6.2ร |
Benchmark conducted on a strictly aligned composite workload on a consumer workstation.
What this means for you:
- Web Apps: Load 6ร more data in the same time budget
- APIs: Serve 6ร more requests with the same infrastructure
- Mobile: Save precious battery and reduce heat
๐ ๏ธ Usage
๐ Web (Browser & Node.js)
Instant data access with zero parsing lag.
import { serialize, ZonReader } from '@zon-lib/zon';
// step 1: serialize to binary (server-side)
const binary = serialize({ name: "Hero", hp: 100 });
// step 2: zero-copy read (client-side)
// ๐ฅ no parsing occurs here โ we simply wrap the memory buffer
const reader = new ZonReader(binary);
// step 3: o(1) direct access
const root = reader.rootOffset;
console.log(reader.readString(root)); // "hero"
Key Benefits:
- โ
No
JSON.parse()overhead - โ Instant data availability
- โ Lower memory pressure
โ๏ธ Systems (Rust)
The core engine for HFT, Game Engines, and System Tools.
use zon_lib::{ZonWriter, ZonReader};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// 1. write with cache-line alignment
let mut writer = ZonWriter::new();
let name_off = writer.write_string("Hero");
// 2. map bytes directly
let buffer = writer.as_bytes();
let reader = ZonReader::new(buffer)?;
// 3. access with zero allocations
let name = reader.read_string(name_off)?;
println!("Name: {}", name);
Ok(())
}
Performance Characteristics:
- โ Zero allocations in hot path
- โ CPU cache-friendly (64-byte aligned)
- โ Safe concurrent access
๐ CLI Inspector
Visualize .zon files without writing code.
# install once
cargo install zon-inspector
# inspect any .zon file
zon-inspector data.zon
Output Example:
๐ฆ ZON File: data.zon
โโ Size: 1.2 KB
โโ Entries: 42
โโ Root Object
โโ name: "Hero"
โโ hp: 100
๐ Documentation
| Platform | Link |
|---|---|
| ๐ Web Guide โ Quick Start, Performance Patterns, Integration Examples | zon.mintlify.app |
| โ๏ธ Rust API Docs โ Complete API Reference, Type Specifications, Memory Layout | docs.rs/zon-lib |
๐ Real-World Use Cases
| Use Case | Description |
|---|---|
| ๐ High-Frequency Trading | Nanosecond order book updates without parsing overhead |
| ๐ฎ Multiplayer Games | Synchronize thousands of entities with zero lag |
| ๐ Telemetry Ingest | Massive logging without JSON stringification cost |
Also Great For:
๐บ๏ธ Geographic data (maps, tiles, GeoJSON) โข ๐ค ML inference pipelines โข ๐ก IoT sensor streams โข ๐ฌ Video/audio metadata
๐ค Contributing
Core Principles:
- ๐ฏ Zero-Copy โ No memory allocations in the hot path
- โก 64-Byte Aligned โ Respect CPU cache line architecture
- ๐ Memory Safe โ Leverage Rust's type system
Development Setup:
# test core rust
cargo test --workspace
# build webassembly package
cd crates/zon-lib && wasm-pack build --target nodejs
๐ License
This project is licensed under the MIT License โ see the LICENSE file for details.
Built with โค๏ธ by Zaim Abbasi โข Released under the MIT License
Dependencies
~275โ760KB
~15K SLoC