# JSON\_LENGTH

Computes the length of a JSON map or array.

```sql
JSON_LENGTH(json)

```

## Arguments

* `json`: a valid JSON array or map.

## Return Value

* the length as an integer.
* SQL NULL if json is not a valid JSON array or map.

## Examples

```sql
SELECT JSON_LENGTH('true');


```

```output

+---------------------+
| JSON_LENGTH('true') |
+---------------------+
|                NULL |
+---------------------+





```

```sql
SELECT JSON_LENGTH('[1,2,3]');


```

```output

+------------------------+
| JSON_LENGTH('[1,2,3]') |
+------------------------+
|                      3 |
+------------------------+
```

```sql
SELECT JSON_LENGTH('{"alpha": 1, "beta": 2}');


```

```output

+----------------------------------------+
| JSON_LENGTH('{"alpha": 1, "beta": 2}') |
+----------------------------------------+
|                                      2 |
+----------------------------------------+
```

> **📝 Note**: A JSON or Javascript null value is distinct from SQL NULL.

***

Modified at: April 4, 2023

Source: [/db/v9.1/reference/sql-reference/json-functions/json-length/](https://docs.singlestore.com/db/v9.1/reference/sql-reference/json-functions/json-length/)

(An index of the documentation is available at /llms.txt)
