> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# JSON_FORMAT

> Compacts and normalizes valid JSON text.

<div className="e6-meta"><span className="e6-eyebrow e6-eyebrow--quiet">Scalar function</span></div>

SQL NULL, empty/whitespace-only text and invalid JSON produce SQL NULL.

## Syntax

### Scalar

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
json_format(json_string)
```

## Arguments

| Name | Type | Required | Description |
| - | - | - | - |
| json\_string | STRING | Yes | JSON text to normalize. |

## Returns

* Type: STRING
* NULL behavior: SQL NULL, empty/whitespace-only text and invalid JSON produce SQL NULL.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Supports window usage | No |
| Exact result | Partial (JSON formatting and numeric representation can change.) |

## Usage notes

* The JSON is parsed and written out again, so its text formatting can change.
* Whitespace, number spelling and object-key order may change; object-key order is not part of the SQL contract.
* Deterministic: The same inputs and settings produce the same result.

## Examples

### Typical behavior

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT json_format('{ "a" : 7 }') AS "value", json_format('bad') AS invalid;
```

| value | invalid |
| - | - |
| \{"a":7} | NULL |

### Format a JSON array

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT json_format('[ 1, true, null ]') AS formatted;
```

| formatted |
| - |
| \[1,true,null] |

## Related functions

* [json\_extract](/query/sql/functions/json/json_extract)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.