silentjson
Zero-allocation JSON boundary scanner and splitter utilizing AVX2 SIMD instructions
About silentjson
This large README is shown as a plain-text preview. Read the full README at the source
# silentjson: The "Just Works" High-Performance JSON Parser for Go
**Author: Igor Ivanuto**
[Русский](./README_RU.md) | [中文](./README_ZH.md) | [Français](./README_FR.md) | [Deutsch](./README_DE.md)
## 📰 Media & Community
* **[Habr]** [silentjson v2.0.0: Hitting the hardware limits, or how we squeezed the maximum out of JSON parsing in Go](https://habr.com/ru/news/1055022/)
* **[Reddit]** [silentjson v2.0.0: Hitting the hardware limits, or how we squeezed the maximum out of JSON parsing in Go](https://www.reddit.com/r/HiLoad/comments/1ulspzc/silentjson_v200_hitting_the_hardware_limits_or/)
[](https://pkg.go.dev/github.com/GenshIv/silentjson)
[](https://goreportcard.com/report/github.com/GenshIv/silentjson)
[](https://github.com/GenshIv/silentjson/actions/workflows/test.yml)

`silentjson` is a highly optimized, reflection-free, and zero-allocation JSON library for Go that delivers extreme performance **without requiring any code generation.**
## 🚀 Why `silentjson`?
In a world of high-performance Go libraries, `silentjson` stands out by providing massive speed boosts with zero developer friction.
- **Fast Parallel Parsing:** For large JSON arrays, `UnmarshalArrayParallel` distributes records across all CPU cores. On a Ryzen 9 7950X3D it sustains ~3.2-3.7 GB/s with full struct binding and ~1.1k allocations per 100k records — 15x faster than `encoding/json` on the same payload, with two orders of magnitude fewer allocations (see benchmarks below).
- **Fast Serial Parsing:** On a single core, `UnmarshalSlice` handles a "chaos" payload (rotating key order, unknown fields, escaped strings, nulls) at ~590 MB/s — faster than easyjson and jsoniter and 2.8x `encoding/json`, with near-zero garbage; on small or very large records it reaches 2.1-9.2 GB/s (see the shape matrix below).
- **Zero Code Generation:** This is the key. Unlike other fast JSON libraries, you don't need to generate any code. There are no extra build steps, no `go:generate` commands to remember, and no complex CI/CD pipeline configurations. **It works out-of-the-box, just like the standard library, only much faster.** This makes it trivial to integrate into any project, including those deployed in Docker or Kubernetes environments.
> [!TIP]
> **🤔 When to use SilentJSON?**
> Use this library for processing large arrays of objects where maximum throughput and minimal memory consumption are critical. However, if you require 100% strict adherence to the JSON specification for rare or non-standard edge cases, it's better to stick with the standard `encoding/json`.
## 📖 The Origin Story
This project was born out of a real-world necessity. While working on a large-scale project that required constant parsing of massive JSON catalogs, we hit a severe performance bottleneck. `easyjson` was still too slow for our specific needs, and fully integrating it would have broken our established workflows due to its code generation requirements.
We desperately needed a lightning-fast alternative that didn't rely on JIT (Just-In-Time compilation) or code generation, but couldn't find one that met our strict requirements at the time. While there are a few alternatives available today, building `silentjson` became a personal "todo" to prove that extreme, reflection-free performance could be achieved with a clean, drop-in API.
## ⚠️ Caveats & Considerations
* **Damaged data policy — process what you can, report the rest.** Real feeds contain damaged records; one broken record must not discard the healthy ones. The strict APIs (`UnmarshalSlice`, `UnmarshalArrayParallel`, plain `StreamDecoder`) fail fast — useful when input is trusted. The tolerant mode parses everything decodable, isolates defects and hands them to you: `UnmarshalSliceTolerant(raw, reg, dst) ([]T, []Problem)` for batch, and `NewStreamDecoder(r, reg).Tolerant(sink func(Problem))` for streams (a damaged record is reported and skipped, the stream continues; structural issues — stray commas, truncation — are reported too, and the valid tail element of an unterminated array is salvaged). What the problems mean is your decision: log, count, or treat as fatal. Tolerant mode costs nothing on clean data (measured identical to strict) and problems are collected without allocating while the input is clean.
* **`unsafe` package:** This library heavily utilizes the `unsafe` package. Use with care.
* **AVX2 chunk splitter (history):** its escape-carry was mis-handled in assembly (a backslash in the last byte of a 32-byte SIMD block desynchronized the string state; records were silently dropped). Found and fixed in May 2026 — the AVX2 splitters are enabled and pinned by `TestSplitterEscapeCarryBoundary` / `TestSplitterMarshalDifferential`.
* **Input Buffer Immutability:** Because strings are mapped directly via zero-copy, the underlying `rawJSON` byte slice **must not be modified** while the parsed objects are still in use. This applies to **unescaped** strings only: escaped strings are always decoded into fresh allocations, and the parser never writes into the input buffer.
* **Memory Retention (Zero-Copy Side Effect):** Because strings hold direct references to the original `rawJSON` buffer, retaining even a single parsed string in memory will prevent the entire underlying JSON byte array from being garbage collected. If you only need to store a small subset of parsed data for a long time, explicitly copy the strings (e.g., using `strings.Clone(val)`).
* **Strictness vs `encoding/json`:** numbers, escapes and trailing data are validated like the standard library, but two laxnesses remain: raw control characters inside string literals are accepted (the standard library rejects them) and invalid UTF-8 bytes pass through unchanged (the standard library substitutes U+FFFD).
* **Unsupported field kinds fail loudly:** structs containing `interface{}`, `map`, `uint`/`uint64`, `chan` or `func` fields produce a registry build error (`Registry.Err()`); `Marshal` panics with a descriptive message. Check the registry once at startup.
* **CPU Usage (Parallel Parsing):** `UnmarshalArrayParallel` is designed to use all available CPU cores to maximize speed for large payloads. It is ideal for batch processing or data pipelines. Avoid using it inside individual, high-concurrency API handlers, as this can lead to excessive goroutine creation. For per-request parsing, `UnmarshalSlice` is the better choice.
* **CPU Architecture Requirements:** The `amd64` implementation uses **AVX2** instructions for value/string scanning when available and falls back to a pure Go scalar implementation otherwise (the array splitter currently always uses the scalar path — see above). The `arm64` implementation is in an **experimental/fallback state**.
## Performance Deep Dive
> **Measured on:** AMD Ryzen 9 7950X3D (32 threads), Linux, Go 1.26. All numbers are medians of 3 runs; every benchmark loop checks errors, so what is measured is real decoding work — never a fast-failing error path.
>
> **Important, May 2026 re-measure:** while making the benchmarks error-checked we found that the previously published multi-GB/s parallel numbers were invalid — the AVX2 chunk splitter silently corrupted arrays containing escaped quotes, and the benchmarks discarded the resulting errors. The assembly escape-carry bug is now **found and fixed** (see CHANGELOG): with the repaired AVX2 splitter, parallel parsing reaches ~3.0 GB/s and the stream paths fully recover (NextRawBlock ~4.0 GB/s). The tables below are the honest, error-checked, correctness-gated numbers. `sonic` runs in its fallback mode on this particular machine (its own init warns), so its rows do not represent native JIT performance.
### 1. Deserialization (Parsing / Unmarshal)
Every parser decodes the identical ~16 MB payload: 100,000 `Employee` records in "chaos" mode — rotating key order, unknown fields, escaped strings, empty arrays and nulls (`BenchmarkParserComparison`, `TestParserComparisonCorrectness` verifies every decoder against `encoding/json` field-by-field).
| Library | Objects/sec | Throughput (MB/s) | Latency (ms/op) | Allocated | Allocs/op |
| :--- | :--- | :--- | :--- | :--- | :--- |
| **SilentJSON** (Parallel) | **19.4M** 👑 | **3161** 👑 | **5.1** 👑 | **~0.2 MB** 👑 | ~1150 (fewest: goccy, ~2, at 17 MB) |
| Goccy | 4.2M | 687 | 23.9 | 17.0 MB | 2 |
| Jsoniter | 3.1M | 512 | 39.1 | 3.1 MB | 431k |
| **SilentJSON** (Serial) | 2.2M | 621 | 25.9 | **~130 KB** 👑 | ~1030 |
| Easyjson (codegen) | 2.0M | 322 | 50.7 | 15.4 MB | 534k |
| Standard (`encoding/json`) | 1.3M | 212 | 77.9 | 1.6 MB | 108k |
| simdjson-go (AST + manual extraction) | 1.0M | 171 | 95.6 | 306 MB | 1.4M |
| Sonic* | 1.0M | 159 | 103.1 | 67.8 MB | 108k |
\* fallback mode on this machine.
On a clean payload (`BenchmarkLargeScaleComparison`, 100k records): **SilentJSON Parallel 2985 MB/s** vs Protobuf 246, Standard 202, buger/jsonparser 178, Sonic* 159.
> [!NOTE]
> **What about `simdjson-go`?**
> `simdjson-go` is a C++ port utilizing SIMD instructions, but its API is purely AST-based: mapping into structs is manual (`FindKey` + typed getters per field), and the `As*()` helpers it needs to fill Go slices allocate heavily (306 MB per 16 MB payload in the run above). SilentJSON's parallel struct binding is ~17x faster end-to-end on this payload while keeping the `encoding/json`-style API — no code generation, no manual extraction.
>
> **Developer Experience Comparison:**
> | Approach | Libraries |
> | :--- | :--- |
> | **Struct-mapping (automatic)** | SilentJSON, Sonic, `encoding/json` |
> | **Codegen required** | easyjson |
> | **AST-only (manual)** | simdjson-go, buger/jsonparser |
```mermaid
xychart-beta
title "Parsing Speed: 100k Chaos Objects (MB/s, Higher is Better)"
x-axis ["SilentJSON Par", "Goccy", "Jsoniter", "Easyjson", "SilentJSON", "Standard", "simdjson", "Sonic*"]
y-axis "MB/s" 0 --> 3400
bar [3161, 687, 512, 317, 626, 212, 169, 159]
```
#### Payload flavors: what do escapes and UTF-8 actually cost?
The same 100k-record array rendered three ways (`BenchmarkPayloadFlavors`) separates the payload properties. The parser does UTF-16/UTF-8 work only on the `\uXXXX` branch of an escaped string; multibyte-but-unescaped text takes the zero-copy path with no unicode validation:
| Flavor (100k records) | SilentJSON Serial | SilentJSON Parallel | Standard |
| :--- | :--- | :--- | :--- |
| clean (plain ASCII) | 648 MB/s | 3630 MB/s | 208 MB/s |
| escaped (10% of strings contain `\"`/`\\`) | 624 MB/s | 3492 MB/s | 205 MB/s |
| utf8 (multibyte runes: `Варшава_中央_łąka`) | 658 MB/s | 3247 MB/s | 207 MB/s |
Takeaways, measured: escapes cost throughput nothing on this parser (they only add allocations for the decoded strings — ~1.2 MB per 16 MB payload), multibyte UTF-8 is free (the scanner looks for `"` and `\` bytes only), and the pre-audit tree could not even complete the escaped row — it failed with a chunk-boundary error (see the splitter fix in the CHANGELOG).
#### Record shapes: many small vs few large vs very large
`BenchmarkShapeComparison` decodes ~14-20 MB of JSON in four record shapes with every parser (small: 500k × 40 B; medium: 100k × 160 B; large: 1k × 14 KB; huge: 8 × 2 MB with a 1.2 MB string, 2048 tags and 4096 scores). Every decoder is verified against `encoding/json` per shape before it is measured (`TestShapeComparisonCorrectness`). With the AVX2 string scanner active (every parser gets an identical loop: a destination preallocated before the timer and reused across iterations; no sink is needed — the calls are opaque and their errors are checked, so nothing can be optimized away):
| Parser (MB/s) | Small | Medium | Large | Huge |
| :--- | :--- | :--- | :--- | :--- |
| **SilentJSON Serial** | 667 | 651 | 3919 | **9188** 👑 |
| **SilentJSON Parallel** | **3555** 👑 | 3656 | 3842 | 9090 |
| Easyjson (codegen) | 383 | 325 | 1464 | 5425 |
| Goccy | 910 | 611 | 1295 | 1396 |
| Jsoniter | 511 | 413 | 1050 | 1613 |
| simdjson-go (AST) | 139 | 153 | 910 | 1948 |
| Standard (`encoding/json`) | 215 | 210 | 727 | 1289 |
| Sonic* | 164 | 160 | 449 | 621 |
\* fallback mode on this machine. Parallel numbers on the 100k-record shapes carry ±7% run-to-run noise.
Shape effects worth knowing: on many small records SilentJSON Parallel leads by a wide margin (3555 MB/s — 3.9x the fastest reflection parser, 16.5x `encoding/json`); serially it is mid-pack there (667 MB/s vs Goccy's 910 — the corrected figure: the previously published 2169 was measured on a 31%-truncated decode, see CHANGELOG). On very large records the string scanner dominates and the AVX2 implementation decides the ranking — it lifted huge-record parsing 4.7x (1935 → 9180 MB/s), putting silentjson ahead of even code-generated easyjson there.
Why every parser dips on Medium (including this one): MB/s counts bytes, but parsing cost is mostly per field and per record. Medium records are the most field-dense shape — a float (`strconv` float parsing alone is ~14% of the serial profile), a nested object and two arrays per ~160 bytes — so they carry the worst work-per-byte ratio (~1.5 ns/byte, now essentially tied with Small's ~1.5 since 2.1.0's per-record grammar checks, vs 0.26 for Large, 0.11 for Huge). Long strings in Large/Huge scan at near memory speed and dilute the per-field cost. The dip hits the reflection-based parsers hardest on this shape (easyjson 383→325, Goccy 910→611 MB/s), while silentjson serial is nearly flat (667→651) — the dip is a property of the workload, not of any parser, and the pre-audit tree measured the same ~620-650 MB/s there.
### Hardware Flexibility (AVX2 vs Pure Go Scalar)
`silentjson` detects CPU features at runtime: AVX2 accelerates value skipping, space scanning and string appending when present; everything else falls back to an optimized pure Go implementation, so the library **never crashes** on older hardware.
The AVX2 chunk splitter is back after its escape-carry repair (May 2026) and delivers a 2.2x advantage over the pure Go path — the regression tests in `splitter_regression_test.go` pin its boundaries against a reference scanner, so a repeat of the silent-corruption bug cannot ship again:
| Library | Mode | Throughput (MB/s) | Latency (ms/op) | Allocs/op |
| :--- | :--- | :--- | :--- | :--- |
| **SilentJSON** | AVX2 (SIMD splitter + kernels) | **3267** ⭐ | 5.0 | 10121 |
| **SilentJSON** | Scalar (Pure Go) | **1651** | 9.9 | 10120 |
| Sonic* | fallback | 159 | 103 | 220k |
| Standard | Pure Go | 212 | 77.9 | 220k |
\* fallback mode on this machine.
### Scalability Across File Sizes (< 1 KB to 12.7 MB)
Throughput of the parallel decoder and the streaming `NextRawBlock` stays flat as the payload grows — no degradation at scale, and the streaming path holds ~1.4 GB/s from 120 KB upward (`BenchmarkSizeScalability`):
| Payload | SilentJSON Parallel | SilentJSON Stream (NextRawBlock) | Standard | Sonic* |
| :--- | :--- | :--- | :--- | :--- |
| 0.65 KB (5 objects) | 113 MB/s | 56 MB/s | 141 MB/s | 105 MB/s |
| 13 KB (100) | 422 MB/s | 972 MB/s | 158 MB/s | 121 MB/s |
| 125 KB (1k) | 541 MB/s | 3407 MB/s | 160 MB/s | 127 MB/s |
| 1.26 MB (10k) | 1761 MB/s | 4404 MB/s | 162 MB/s | 123 MB/s |
| 12.67 MB (100k) | 3218 MB/s | 4780 MB/s | 149 MB/s | 124 MB/s |
\* fallback mode on this machine. On tiny payloads per-call overhead dominates; from ~1 MB the parallel decoder reaches its AVX2-splitter steady state.
```mermaid
xychart-beta
title "Parsing Throughput vs File Size (MB/s, Higher is Better)"
x-axis "File Size" ["0.65KB", "13KB", "125KB", "1.26MB", "12.7MB"]
y-axis "Speed (MB/s)" 0 --> 5000
line "SilentJSON Stream" [56, 972, 3407, 4404, 4780]
line "SilentJSON Parallel" [113, 422, 541, 1761, 3218]
line "Standard" [141, 158, 160, 162, 149]
```
> **Legend:**
> 🔵 **Top Line:** `SilentJSON` stream (NextRawBlock, ramps to ~4.8 GB/s)
> 🟣 **Middle Line:** `SilentJSON` parallel struct binding (ramps to ~3.2 GB/s)
> 🔴 **Bottom Line:** `Standard` (~150 MB/s)
### 2. Stream Parsing (io.Reader)
When you are downloading gigabytes of JSON arrays over the network and want to parse them on-the-fly without loading the entire payload into RAM, you need a streaming parser.
Because `simdjson` and `sonic` (for standard arrays) require the **entire** payload in memory, they cannot perform streaming array processing. `SilentJSON` includes a specialized `StreamDecoder` that uses an optimized boundary scanner to process infinite streams. Measured on a 500 MB stream of 3M chaos-mode records (`BenchmarkStreamComparison`):
Two different jobs are measured here, so the table is split: **raw chunk extraction** (no struct binding — you get the object bytes) and **full struct binding** (decoded Go values). Measured on a 500 MB stream of 3M chaos-mode records (`BenchmarkStreamComparison`).
Raw chunk extraction (no struct binding):
| Mode | Throughput (MB/s) | Allocated | Allocs/op |
| :--- | :--- | :--- | :--- |
| **SilentJSON (NextRawBlock)** | **4344** 🚀 | **~0.5 MB** | **5.7k** |
| SilentJSON (NextRaw) | 2640 | 527 MB | 3.0M |
Full struct binding:
| Library / Mode | Throughput (MB/s) | Allocated | Allocs/op | Notes |
| :--- | :--- | :--- | :--- | :--- |
| **SilentJSON (NextChanParallel)** | **2182** | 147 MB | 10.6M | 16 worker goroutines overlap parsing with I/O |
| Jsoniter (Stream) | 479 | 149 MB | 14.6M | — |
| SilentJSON (Next / Decode) | 386 | 263 MB | 37.5M | Reusable object; identical cost for both APIs |
| SilentJSON (NextChan) | 351 | 263 MB | 37.5M | Async producer-consumer, 1 worker |
| Standard (`json.NewDecoder`) | 143 | **107 MB** 👑 | **5.1M** 👑 | Slowest throughput, leanest memory |
```mermaid
xychart-beta
title "Streaming Throughput (MB/s) - Higher is Better"
x-axis ["Standard", "NextChan", "Decode", "Jsoniter", "NextChanPar", "NextRaw", "NextRawBlock"]
y-axis "MB/s" 0 --> 4700
bar [143, 515, 570, 479, 2182, 2640, 4344]
```
*Honest reading of the struct-binding group: **silentjson's Next/Decode now leads single-thread struct binding (568 vs jsoniter's 454 MB/s)** — keys are matched in place (zero-copy, ~9 fewer allocations per record) and numbers take the single-pass fast path. The standard library remains the leanest on memory (107 MB) while being the slowest; silentjson's stream now allocates 84 MB / 10.5M allocs per 500 MB, down from 263 MB / 37.5M. `NextRawBlock()` remains in a class of its own (~4.0 GB/s, near-zero allocations) when struct binding is not needed, and `NextChanParallel` trades memory for 2 GB/s with binding.*
### 3. Serialization (Generation / Marshal)
We benchmarked generating a JSON array of 100,000 complex objects (`BenchmarkLargeScaleGeneration`). `simdjson-go` is excluded as it is a parser only.
| Library | Throughput (MB/s) | Latency (ms/op) | Allocated | Allocs/op |
| :--- | :--- | :--- | :--- | :--- |
| **SilentJSON** | **1248** 👑 | **12.7** 👑 | **0 (Zero-Alloc)** 👑 | **0** 👑 |
| Protobuf | 437 | 15.4 | 6.8 MB | 1 |
| Standard (`encoding/json`) | 423 | 37.7 | 15.9 MB | 3 |
| Sonic* | 416 | 38.2 | 15.9 MB | 5 |
\* fallback mode on this machine.
```mermaid
xychart-beta
title "Serialization Throughput: 100k Objects (MB/s, Higher is Better)"
x-axis ["SilentJSON", "Protobuf", "Standard", "Sonic*"]
y-axis "MB/s" 0 --> 1400
bar [1248, 437, 423, 416]
```
### Benchmark Methodology & Fairness
To ensure our benchmarks are as fair and accurate as possible, we strictly adhere to the following principles:
Frequently Asked Questions
What is silentjson?
silentjson is a JSON library for the Go programming language. Zero-allocation JSON boundary scanner and splitter utilizing AVX2 SIMD instructions
How do I install silentjson?
Install silentjson with the Go module system using `go get GenshIv/silentjson`. Check the repository for the current installation instructions.
What category does silentjson belong to?
silentjson is listed under JSON, specifically JSON.