# JSON_PRETTY

> JSON_PRETTY function in StackQL: format a JSON value across lines with indentation for reading.

Source: https://stackql.io/language-spec/functions/json/json_pretty

Returns a JSON value formatted across several lines with indentation, for reading nested provider fields.

See also:  
[[` SELECT `]](/language-spec/select) [[` JSON `]](/language-spec/functions/json/json-fn) [[` JSON_EXTRACT `]](/language-spec/functions/json/json_extract)

* * * 

## Syntax

```sql
SELECT JSON_PRETTY(json_value [, indent]) FROM <multipartIdentifier>;
```

## Arguments

__*json_value*__  
A JSON string.

__*indent*__  
Optional.  The string used for each level of indentation.  Four spaces when omitted.

## Return Value(s)
Returns a JSON string.  An argument that is not valid JSON raises an error.

* * *

## Examples

### Indent with two spaces

The second argument sets the indentation:

```sql
SELECT JSON_PRETTY('{"a":[1,2]}', '  ') AS v;
```

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

### Read a nested provider field

The following query formats the `license` object of a repository in a GitHub organization:

```sql
SELECT name, JSON_PRETTY(license) AS license
FROM github.repos.repos
WHERE org = 'stackql-labs'
AND license IS NOT NULL
LIMIT 1;
```

For more information, see [https://www.sqlite.org/json1.html#jpretty](https://www.sqlite.org/json1.html#jpretty)
