It’s like the JSON1 extension. But binary — faster and smaller.
sqlite-msgpack adds functions for creating, querying, and mutating
MessagePack BLOBs directly inside SQL.
The API mirrors SQLite’s built-in JSON1 functions, so
msgpack_extract, msgpack_set, and
msgpack_each feel instantly familiar.
Same data, 9 fewer bytes (33%) — and on real records the
savings compound. Stored as an ordinary SQLite BLOB.
A complete, deterministic, side-effect-free MessagePack toolkit that lives inside your queries.
Path syntax and function names mirror json_extract, json_set, and json_each. No new mental model to learn.
Compact binary encoding with the smallest-format rule. Builds and extractions routinely beat JSON and JSONB.
Validate BLOBs against a JSON-Schema-style contract right in CHECK constraints and triggers.
Every mutation returns a new BLOB; originals are never modified. All functions are deterministic.
Native Blob libraries for C++, Python, JS/TS, Rust, and Go produce byte-identical output. Blobs round-trip freely.
All 36 MessagePack format families, ext types, and the timestamp extension — with hard limits on untrusted blobs.
Once the extension is loaded, every msgpack_* function is available in every connection.
-- Build a map and extract from it
SELECT msgpack_extract(
msgpack_object('name', 'Alice', 'age', 30),
'$.name'
); -- Alice
-- Update a value (returns a new BLOB; original is unchanged)
SELECT msgpack_to_json(
msgpack_set(msgpack_object('a', 1), '$.b', 2)
); -- {"a":1,"b":2}
-- Convert to and from JSON
SELECT msgpack_to_json(msgpack_from_json('[1,true,"hi"]')); -- [1,true,"hi"]
-- Aggregate rows into a msgpack array
CREATE TABLE t(v INTEGER);
INSERT INTO t VALUES (1),(2),(3);
SELECT msgpack_to_json(msgpack_group_array(v)) FROM t; -- [1,2,3]
Beyond the SQLite extension, the Blob API ships as self-contained, zero-dependency packages. Output is byte-identical across all of them.
The canonical implementation. C++17, header + source, no dependencies.
Py PythonPure-stdlib port. Python ≥ 3.7, no third-party packages.
TS TypeScript / JSESM, no dependencies. Runs on Node ≥ 18 and modern runtimes.
Rs RustSafe, zero-dependency crate targeting Rust ≥ 1.70.
Go GoIdiomatic, stdlib-only package for Go ≥ 1.21.
📊 BenchmarksSee how msgpack compares to JSON and JSONB on speed and size.
Build from source with CMake, load the extension, and start querying binary documents in SQL.