sonic-rs

A fast Rust JSON library powered by SIMD for high-throughput parsing, serialization, and querying.

Library
Cargo
v0.5.8
915stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
49/100Fair
Development Activity12
Maintenance44
Community48
Maturity52
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
83/100Excellent
Architecture88
Code Quality85
Innovation85
Learning Curve75

sonic-rs is a high-performance JSON library for Rust that leverages SIMD instructions to parse, serialize, and query JSON documents significantly faster than serde_json and simd-json. It offers a drop-in, serde-compatible API for deserializing into Rust structs, plus a mutable untyped Value document, lazy iterators, and pointer-based field access.

Built by the CloudWeGo team, sonic-rs draws on techniques from sonic-cpp, simdjson, and serde_json, using a memory arena and direct-to-struct parsing to avoid intermediate representations. It runs on stable Rust and is optimized for x86_64 and aarch64 targets.

What You Get

  • A drop-in, serde-compatible from_str/to_string API that re-exports Serialize/Deserialize
  • A mutable untyped sonic_rs::Value document backed by a memory arena
  • Pointer-based field access with get and get_unchecked for blazing-fast extraction
  • Lazy array and object iterators plus LazyValue, Number, and RawNumber types
  • SIMD-accelerated parsing and serialization on x86_64 and aarch64

Common Use Cases

  • Replacing serde_json in throughput-critical services to cut deserialization time
  • Extracting a handful of fields from large JSON payloads without full parsing
  • Serializing high-volume API responses with lower CPU overhead
  • Streaming through large JSON arrays or objects with lazy iterators

Under The Hood

Architecture

sonic-rs is organized as a Cargo workspace with the core crate in src/ alongside two internal crates, sonic-number (fast integer/float parsing and formatting) and sonic-simd (portable SIMD abstractions). The parser reads bytes directly into Rust structs without building an intermediate tape (unlike simd-json), and the untyped Value document is allocated inside a bumpalo memory arena, giving fewer allocations, better cache locality, and cheap mutability. SIMD is applied selectively to string parsing, float fraction decoding, whitespace skipping, and pointer-based field lookup rather than as a blanket two-stage pass.

Tech Stack

Written in Rust (edition 2021, stable toolchain) with serde for the derive-based typed API, bumpalo for arena allocation, simdutf8 for fast UTF-8 validation, ahash for hashing, faststr for string handling, itoa and zmij for number formatting, and thiserror for error types. The workspace ships benchmarks, fuzz targets, and language bindings.

Code Quality

The repo is mature and well-tooled: it carries a fuzz/ directory for fuzz testing, a benchmarks/ suite benchmarked against serde_json and simd-json, runnable examples/, plus clippy, rustfmt, taplo, and typos configuration. CI, codecov coverage, a code of conduct, and contributing guidelines are all present, signalling disciplined maintenance.

API Design

The public API is deliberately familiar to serde users, re-exporting Serialize/Deserialize so migration is often a namespace swap. The pointer! macro and get/get_unchecked functions make targeted field extraction ergonomic, and the docs include dedicated migration and Golang-user guides. The main friction is the requirement to compile with -C target-cpu=native to unlock SIMD, and the _unchecked variants that trade safety for speed on trusted input.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search