SQLite 3 reference · JSON Functions

SQLite JSON_PRETTY() Function

Return JSON formatted with new lines and indentation (4 spaces by default) so it's easy to read.

SQLite 3 Since 3.46.0

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

Syntax

json_pretty(json, indent)

Parameters

ParameterDescription
json JSON text (or JSONB).
indent optional The indentation text. Default: four spaces

Return value

Formatted JSON text.

Examples

Pretty-printTry it yourself
SELECT json_pretty('{"name":"Ada","tags":["math","code"]}') AS pretty;

Output

pretty
{
    "name": "Ada",
    "tags": [
        "math",
        "code"
    ]
}
Custom indentationTry it yourself
SELECT json_pretty('[1,{"a":2}]', '  ') AS two_spaces;

Output

two_spaces
[
  1,
  {
    "a": 2
  }
]

Version history

VersionChange
SQLite 3.46.0Added

In other languages

Was this page helpful?