📣
TiDB Cloud Premium is now in public preview. Unlimited growth, instant elasticity, advanced security for enterprise workloads. Try it out →

JSON_PRETTY



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" │ │ } │ │ } │ └───────────────────────────────────────────────────────────────────────────────────────┘

Was this page helpful?