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" │
│ } │
│ } │
└───────────────────────────────────────────────────────────────────────────────────────┘
Try Databend Cloud for FREE

Multimodal, object-storage-native warehouse for BI, vectors, search, and geo.

Snowflake-compatible SQL with automatic scaling.

Sign up and get $200 in credits.

Try it today