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
Syntax
json_pretty(json, indent)
Parameters
| Parameter | Description |
|---|---|
json |
JSON text (or JSONB). |
indent optional |
The indentation text. Default: four spaces |
Return value
Formatted JSON text.
Examples
SELECT json_pretty('{"name":"Ada","tags":["math","code"]}') AS pretty;
Output
pretty
{
"name": "Ada",
"tags": [
"math",
"code"
]
}SELECT json_pretty('[1,{"a":2}]', ' ') AS two_spaces;
Output
two_spaces
[
1,
{
"a": 2
}
]Version history
| Version | Change |
|---|---|
| SQLite 3.46.0 | Added |
In other languages
JSONB_PRETTY()· PostgreSQL
Related
JSON()· Check and minify JSON text: return it without extra whitespace, or raise an error if it isn't valid JSON.- SQL String Functions · tutorial