# JSON

> JSON function in StackQL: validate a JSON value and return it in canonical minified form, accepting JSON5 input.

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

Checks that its argument is valid JSON and returns it in canonical, minified form.  JSON5 input, such as unquoted keys, is accepted and converted to standard JSON.

See also:  
[[` SELECT `]](/language-spec/select) [[` JSON_VALID `]](/language-spec/functions/json/json_valid) [[` JSON_PRETTY `]](/language-spec/functions/json/json_pretty)

* * * 

## Syntax

```sql
SELECT JSON(json_value) FROM <multipartIdentifier>;
```

## Arguments

__*json_value*__  
A JSON or JSON5 string.

## Return Value(s)
Returns a JSON string.  An argument that is not valid JSON or JSON5 raises an error; use [`JSON_VALID`](/language-spec/functions/json/json_valid) to test a value first.

* * *

## Examples

### Minify a JSON value

Whitespace is removed:

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

```
|-------------|
|      v      |
|-------------|
| {"a":[1,2]} |
|-------------|
```

### Convert JSON5 to JSON

The unquoted key is quoted in the result:

```sql
SELECT JSON('{a:1}') AS v;
```

```
|---------|
|    v    |
|---------|
| {"a":1} |
|---------|
```

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