SQLite 3 reference · JSON Functions

SQLite JSONB() Function

Convert JSON text to SQLite's binary JSONB format, which is faster to process. Every json_ function has a jsonb_ version.

SQLite 3 Since 3.45.0

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

jsonb(X)

Parameters

ParameterDescription
X JSON text or JSONB.

Return value

A BLOB in JSONB format.

Examples

Convert and backTry it yourself
SELECT typeof(jsonb('{"a":1}')) AS stored_as, json(jsonb('{"a": 1}')) AS back_to_text;

Output

stored_as | back_to_text
blob | {"a":1}
jsonb_ functionsTry it yourself
SELECT jsonb_extract(jsonb('{"a":[1,2]}'), '$.a[1]') AS value;

Output

value
2

JSONB is SQLite's own format, not PostgreSQL's jsonb: store it in BLOB columns and read it back with json() when you need text.

Version history

VersionChange
SQLite 3.45.0Added

Was this page helpful?