Parsing gigabytes of JSON per second : used by Facebook/Meta Velox, the Node.js runtime, ClickHouse, WatermelonDB, Apache Doris, Milvus, StarRocks https://simdjson.org
  • C++ 94.2%
  • HTML 2.1%
  • CMake 1.2%
  • C 0.9%
  • Python 0.9%
  • Other 0.7%
Find a file
Daniel Lemire b0fcd0ca15
On-Demand: report a second string read in development checks (#3163)
* On-Demand: report a second string read in development checks

Calling get_string() or get_wobbly_string() twice on the same value
unescapes the string into the parser's string buffer a second time.
The buffer is sized for one pass over the document, so a long string
read twice overflows it. With development checks, the string getters
now return OUT_OF_ORDER_ITERATION when the value was already consumed.
Release builds are unchanged.

Two tests read a string value twice and are updated to read it once.

Fixes #3162

* Read the string before the number in crypto_infinity

With SIMDJSON_ENABLE_NAN_INF, get_double_in_string() succeeds on
"Infinity" and consumes the value, so the get_string() that followed
returned OUT_OF_ORDER_ITERATION under development checks.
2026-12-03 08:22:10 -05:00
.github rvv: fix C++11 builds at VLEN256 (#3167) 2026-12-03 08:21:36 -05:00
.vscode let us default on developer mode when building with VScode 2025-08-23 20:59:58 -04:00
benchmark ondemand: add document::validate() to check a whole document (#3114) (#3117) 2026-11-20 14:01:50 -05:00
cmake cmake: offline developer builds work as packaged, and are tested in CI (#3007) 2026-10-31 10:04:06 -04:00
dependencies tools: keep only minify, renamed sjmin, with a manual page (#3142) 2026-11-23 07:58:11 -05:00
doc doc/sjmin.md: to_json_string is not a minifier; narrow error-format sentence [skip ci] (#3146) 2026-11-23 19:49:17 -05:00
examples Detect C++26 static reflection instead of requiring a build flag (#2798) 2026-08-04 14:10:03 -04:00
extra Removing all stdout, stderr from main library. (#455) 2020-01-20 16:03:15 -05:00
fuzz tools: move sjq to its own repository (simdjson/sjq) (#3145) 2026-11-23 11:39:56 -05:00
images adjust logo image file names (*_simdjason_* -> *_simdjson_*) (#2569) 2025-12-19 23:21:59 -05:00
include On-Demand: report a second string read in development checks (#3163) 2026-12-03 08:22:10 -05:00
jsonexamples Add Glaze to benchmarks; deserialize strings and large container elements in place (#2896) 2026-10-01 08:20:57 -04:00
man sjmin: use -V for --version, add doc/sjmin.md (#3144) 2026-11-23 19:47:00 -05:00
p2996 [skip ci] Fix dead P2996R10 paper link in p2996/README.md (#3081) 2026-11-19 10:13:30 -05:00
scripts tools: keep only minify, renamed sjmin, with a manual page (#3142) 2026-11-23 07:58:11 -05:00
singleheader 5.3.0 2026-11-22 23:05:51 +00:00
src Decode adjacent simple escapes in parse_string without rescanning (#3166) 2026-12-03 08:21:51 -05:00
style Hiding the pointer away... (#252) 2019-08-04 15:41:00 -04:00
tests On-Demand: report a second string read in development checks (#3163) 2026-12-03 08:22:10 -05:00
tools sjmin: use -V for --version, add doc/sjmin.md (#3144) 2026-11-23 19:47:00 -05:00
windows This adds /permissive- to recent visual studio builds (#1596) 2021-06-01 10:57:37 -04:00
.clang-format We are adopting clang-format. 2019-08-01 15:40:07 -04:00
.clangd Make simdjson compile again 2024-08-18 11:21:26 -07:00
.dockerignore move amalgamate from bash to python (#1278) 2020-11-03 07:35:16 +01:00
.editorconfig [skip ci] Add an .editorconfig for .cpp/.h/.md for whitespace settings (#1901) 2022-10-03 11:14:00 -04:00
.gitattributes [skip ci] Add an .editorconfig for .cpp/.h/.md for whitespace settings (#1901) 2022-10-03 11:14:00 -04:00
.gitignore remove cmake_policy (#2404) 2025-07-31 10:18:28 -04:00
AGENTS.md AGENTS.md: run tests with development checks, describe the builder [skip ci] (#3164) 2026-12-02 14:42:21 -05:00
AI_USAGE_POLICY.md Update AI usage policy regarding disclosure 2026-11-21 14:06:48 -05:00
AUTHORS Update AUTHORS 2020-04-30 19:49:20 -04:00
CMakeLists.txt tools: keep only minify, renamed sjmin, with a manual page (#3142) 2026-11-23 07:58:11 -05:00
CONTRIBUTING.md [skip ci] Add AGENTS.md for coding agents 2026-11-19 14:07:48 -05:00
CONTRIBUTORS Update CONTRIBUTORS 2022-05-25 11:24:40 -04:00
Doxyfile 5.3.0 2026-11-22 23:05:51 +00:00
HACKING.md tools: keep only minify, renamed sjmin, with a manual page (#3142) 2026-11-23 07:58:11 -05:00
LICENSE Introducing dual licensing (#2328) 2025-01-27 20:34:35 -05:00
LICENSE-MIT Introducing dual licensing (#2328) 2025-01-27 20:34:35 -05:00
README.md README: sjq 0.3.0 speed and package managers [skip ci] (#3147) 2026-12-01 00:24:23 +01:00
SECURITY.md Create SECURITY.md 2024-02-09 17:16:54 -05:00
simdjson.pc.in build: add pkg-config support (#1767) 2022-08-26 16:20:51 -04:00

Doxygen Documentation

simdjson : Parsing gigabytes of JSON per second

JSON is everywhere on the Internet. Servers spend a lot of time parsing it. We need a fresh approach. The simdjson library uses commonly available SIMD instructions and microparallel algorithms to parse JSON 4x faster than RapidJSON and 25x faster than JSON for Modern C++.

  • Fast: Over 4x faster than commonly used production-grade JSON parsers.
  • Record Breaking Features: Minify JSON at 6 GB/s, validate UTF-8 at 13 GB/s, NDJSON at 3.5 GB/s.
  • Easy: First-class, easy to use and carefully documented APIs.
  • Strict: Full JSON and UTF-8 validation, lossless parsing. Performance with no compromises.
  • Automatic: Selects a CPU-tailored parser at runtime. No configuration needed.
  • Reliable: From memory allocation to error handling, simdjson's design avoids surprises.
  • Peer Reviewed: Our research appears in venues like VLDB Journal, Software: Practice and Experience.

Table of Contents

Real-world usage

If you are planning to use simdjson in a product, please work from one of our releases.

Quick Start

The simdjson library is easily consumable with a single .h and .cpp file.

  1. Prerequisites: g++ (version 7 or better) or clang++ (version 6 or better), and a 64-bit system with a command-line shell (e.g., Linux, macOS, freeBSD). We also support programming environments like Visual Studio and Xcode, but different steps are needed. Users of clang++ may need to specify the C++ version (e.g., c++ -std=c++17) since clang++ tends to default on C++98.

  2. Pull simdjson.h and simdjson.cpp into a directory, along with the sample file twitter.json. You can download them with the wget utility:

    wget https://raw.githubusercontent.com/simdjson/simdjson/master/singleheader/simdjson.h https://raw.githubusercontent.com/simdjson/simdjson/master/singleheader/simdjson.cpp https://raw.githubusercontent.com/simdjson/simdjson/master/jsonexamples/twitter.json
    
  3. Create quickstart.cpp:

#include <iostream>
#include "simdjson.h"
using namespace simdjson;
int main(void) {
    ondemand::parser parser;
    padded_string json = padded_string::load("twitter.json");
    ondemand::document tweets = parser.iterate(json);
    std::cout << uint64_t(tweets["search_metadata"]["count"]) << " results." << std::endl;
}
  1. c++ -o quickstart quickstart.cpp simdjson.cpp
  2. ./quickstart
 100 results.

Documentation

Usage documentation is available:

  • Basics is an overview of how to use simdjson and its APIs.
  • Builder is an overview of how to efficiently write JSON strings using simdjson.
  • Performance shows some more advanced scenarios and how to tune for them.
  • Implementation Selection describes runtime CPU detection and how you can work with it.
  • API contains the automatically generated API documentation.
  • Compile-Time Parsing presents our compile-time parsing function (C++26 only).

Godbolt

Some users may want to browse code along with the compiled assembly. The following examples use simdjson 5.0.1:

Performance results

The simdjson library uses three-quarters less instructions than state-of-the-art parser RapidJSON. To our knowledge, simdjson is the first fully-validating JSON parser to run at gigabytes per second (GB/s) on commodity processors. It can parse millions of JSON documents per second on a single core.

The following figures show how fast simdjson maps JSON to and from your own C++ structs, using C++26 static reflection with GCC 16.2 (-O3). The task is to parse twitter.json into native data structures and to serialize them back to JSON, on an Intel Xeon Gold 6548N (Emerald Rapids) processor. We compare against the fastest C, C++ and Rust libraries, including Glaze and Serde. The simdjson library offers full unicode (UTF-8) validation and exact number parsing. You can reproduce these results with our static reflection benchmarks.

Parsing twitter.json into native structs: simdjson 5.11 GB/s, Serde 1.85 GB/s, Glaze 1.67 GB/s, yyjson 1.18 GB/s, RapidJSON 0.85 GB/s, nlohmann::json 0.15 GB/s Serializing native structs to twitter.json: simdjson 11.2 GB/s, Glaze 6.72 GB/s, Serde 1.85 GB/s, yyjson 1.55 GB/s, reflect-cpp 1.20 GB/s, nlohmann::json 0.19 GB/s

The simdjson library offers high speed whether it processes tiny files (e.g., 300 bytes) or larger files (e.g., 3MB).

All our experiments are reproducible.

For NDJSON files, we can exceed 3 GB/s with our multithreaded parsing functions.

Packages

Packaging status

Companion libraries

The simdjson organization maintains libraries and tools built on simdjson:

  • fastsimdjson: our official Python bindings (pip install fastsimdjson). A drop-in replacement for the json module's loads, load, dumps and dump, over 3 times faster than the standard library. It also offers lazy parsing, multithreaded NDJSON with free-threaded Python, and conversion to Apache Arrow and MessagePack.
  • simdjson_arrow: reads newline-delimited JSON into Apache Arrow record batches, and writes Arrow record batches as JSON, on one thread or many. Several times faster than Arrow C++'s own JSON reader.
  • simdjson_msgpack: converts JSON to MessagePack and back, one document or many, on many threads.
  • sjq: a jq-compatible command-line JSON processor, ten to almost two hundred times faster than jq on large inputs. Prebuilt binaries for Linux, macOS and Windows, also through Homebrew (brew install simdjson/tap/sjq) and Scoop.

Bindings and Ports of simdjson

We distinguish between "bindings" (which just wrap the C++ code) and a port to another programming language (which reimplements everything).

About simdjson

The simdjson library takes advantage of modern microarchitectures, parallelizing with SIMD vector instructions, reducing branch misprediction, and reducing data dependency to take advantage of each CPU's multiple execution cores.

Our default front-end is called On-Demand, and we wrote a paper about it:

Some people enjoy reading the first (2019) simdjson paper: A description of the design and implementation of simdjson is in our research article:

We have an in-depth paper focused on the UTF-8 validation:

We also have an informal blog post providing some background and context.

For the video inclined, we had a talk at QCon San Francisco 2019
simdjson at QCon San Francisco 2019
(It was the best voted talk, we're kinda proud of it.)

We also had a CppCon 2025 talk. We show how C++26 reflection allows for one-line serialization (to_json(player)) or deserialization—without invasive macros or manual mapping—using nothing but the C++ standard library. Whether you’re a performance junkie or simply interested in the roadmap for the next decade of C++ development, watch our full talk!

simdjson at CppCon 2025

Citing this work

If you use simdjson in published research, please cite the software library. A suitable BibTeX entry is:

@misc{simdjson,
  title={{The simdjson library: Parsing Gigabytes of JSON per Second}},
  author={Daniel Lemire and Geoff Langdale and John Keiser and Paul Dreik and Francisco Thiesen and others},
  year={2019},
  howpublished={Software library},
  note={https://github.com/simdjson/simdjson}
}

Funding

The work is supported by the Natural Sciences and Engineering Research Council of Canada under grants RGPIN-2017-03910 and RGPIN-2024-03787.

Contributing to simdjson

Head over to CONTRIBUTING.md for information on contributing to simdjson, and HACKING.md for information on source, building, and architecture/design.

License

This code is made available under the Apache License 2.0 as well as under the MIT License. As a user, you can pick the license you prefer.

Under Windows, we build some tools using the windows/dirent_portable.h file (which is outside our library code): it is under the liberal (business-friendly) MIT license.

For compilers that do not support C++17, we bundle the string-view library which is published under the Boost license. Like the Apache license, the Boost license is a permissive license allowing commercial redistribution.

For efficient number serialization, we bundle a port of Victor Zverovich's Żmij algorithm for binary to decimal floating-point numbers (https://github.com/vitaut/zmij). Żmij is provided under the MIT License or the Boost Software License Version 1.0 (https://www.boost.org/LICENSE_1_0.txt).

For runtime dispatching, we use some code from the PyTorch project licensed under 3-clause BSD.