# json_array_length

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [cloud-data-platform-full.txt](https://docs.redpanda.com/cloud-data-platform-full.txt)

---
title: json_array_length
latest-operator-version: v26.1.4
latest-console-tag: v3.7.3
latest-connect-version: 4.93.0
latest-redpanda-tag: v26.1.9
docname: sql/sql-functions/json-functions/json-array-length
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: sql/sql-functions/json-functions/json-array-length.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/reference/pages/sql/sql-functions/json-functions/json-array-length.adoc
description: The `json_array_length()` function returns the length of a specified JSON array.
page-topic-type: reference
page-git-created-date: "2026-05-26"
page-git-modified-date: "2026-05-26"
---

<!-- Source: https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-functions/json-functions/json-array-length.md -->

The `json_array_length()` function returns the length of a specified `json` array.

## [](#syntax)Syntax

This function has the following basic syntax.

```sql
JSON_ARRAY_LENGTH(arrayval JSON)
```

The required argument for this function is `arrayval`. It represents the `json` array for which to count the length.

## [](#examples)Examples

### [](#get-a-json-array-length-with-a-json-value)Get a JSON array length with a JSON value

The following example returns the number of elements in the array:

```sql
SELECT JSON_ARRAY_LENGTH('[4, 7, 10, 11, 14, {"vegetables":"spinach","fruits":"melon"}, {"a":"b"}]');
```

This function returns the following result:

```sql
+-------+
| f     |
+-------+
| 7     |
+-------+
```

### [](#get-a-json-array-length-with-a-number)Get a JSON array length with a number

The following example returns the number of elements in the array.

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

The query returns:

```sql
+-------+
| f     |
+-------+
| 3     |
+-------+
```

### [](#json-array-length-where-the-array-is-null-or-empty)JSON array length where the array is NULL or empty

This example shows that an empty `json` array returns 0.

```sql
SELECT JSON_ARRAY_LENGTH('[]');
```

An empty array returns 0:

```sql
+-------+
| f     |
+-------+
| 0     |
+-------+
```