SQLite 3 reference · JSON Functions

SQLite JSON() Function

Check and minify JSON text: return it without extra whitespace, or raise an error if it isn't valid JSON.

SQLite 3 Since 3.9.0

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

Syntax

json(X)

Parameters

ParameterDescription
X JSON text.

Return value

Minified JSON text.

Examples

Minify JSONTry it yourself
SELECT json(' { "name" : "Ada",  "tags" : [ 1, 2 ] } ') AS compact;

Output

compact
{"name":"Ada","tags":[1,2]}
Validate first with json_valid()Try it yourself
SELECT json_valid('{"a": 1}') AS good, json_valid('{a: 1}') AS bad;

Output

good | bad
1 | 0

Version history

VersionChange
SQLite 3.9.0Added
SQLite 3.38.0Built in by default; earlier versions needed the JSON1 extension.

Was this page helpful?