Skip to main content

JSON_PRETTY

Introduced or updated: v1.2.77

Formats JSON data, making it more readable and presentable. It automatically adds indentation, line breaks, and other formatting to the JSON data for better visual representation.

Syntax

JSON_PRETTY(<json_string>)

Return Type

String.

Examples

SELECT JSON_PRETTY(PARSE_JSON('{"name":"Alice","age":30}'));

---
┌──────────────────────────────────────────────────────┐
│ json_pretty(parse_json('{"name":"alice","age":30}'))
│ String │
├──────────────────────────────────────────────────────┤
│ { │
"age": 30,
"name": "Alice"
│ } │
└──────────────────────────────────────────────────────┘

SELECT JSON_PRETTY(PARSE_JSON('{"person": {"name": "Bob", "age": 25}, "location": "City"}'));

---
┌───────────────────────────────────────────────────────────────────────────────────────┐
│ json_pretty(parse_json('{"person": {"name": "bob", "age": 25}, "location": "city"}'))
│ String │
├───────────────────────────────────────────────────────────────────────────────────────┤
│ { │
"location": "City",
"person": { │
"age": 25,
"name": "Bob"
│ } │
│ } │
└───────────────────────────────────────────────────────────────────────────────────────┘
Explore Databend Cloud for FREE
Low-cost
Fast Analytics
Easy Data Ingestion
Elastic Scaling
Try it today