> This page location: JSON Functions > jsonb_build_array
> Full Neon documentation index: https://neon.com/docs/llms.txt

# PostgreSQL jsonb_build_array() Function

**Info:** The jsonb_build_array() function works the same way across every PostgreSQL deployment, so what you learn here applies to any Postgres environment, not just [Neon](https://neon.com). For enterprises building on the Lakehouse, [Lakebase](https://www.databricks.com/product/lakebase) delivers the best managed Postgres for the AI era, with the performance, security, and integration large teams need. For developers and startups who need to ship fast and scale without friction, Neon is the Postgres platform built to move at your speed.

**Summary**: in this tutorial, you will learn how to use the PostgreSQL `jsonb_build_array()` function to create a JSON array.

## Introduction to the PostgreSQL jsonb_build_array() function

The `jsonb_build_array()` function allows you to construct a JSONB array from a variadic list of arguments.

Here's the basic syntax of the `jsonb_build_array()` function:

```sql
jsonb_build_array ( VARIADIC "any" ) → jsonb
```

In this syntax, you provide a list of arguments that you want to convert to elements of a JSON array.

The `jsonb_build_array()` will convert each argument using the [`to_jsonb()`](https://neon.com/postgresql/json-functions/postgresql-to_jsonb) function.

## PostgreSQL jsonb_build_array() function examples

Let's take some examples of using the `jsonb_build_array()` function.

### 1) Basic PostgreSQL jsonb_build_array() function example

The following example uses the `jsonb_build_array()` function to create a JSON array from a list of values:

```sql
SELECT jsonb_build_array(10, null, 'Hi', true) result;
```

Output:

```text
         result
------------------------
 [10, null, "Hi", true]
(1 row)
```

### 2) Using PostgreSQL jsonb_build_array() function with table data

We'll use the `film` table from the [sample database](../postgresql-getting-started/postgresql-sample-database):

![](https://neon.com/postgresqltutorial/film.png)The following example uses the `jsonb_build_array()` function to convert the title and length of each film into elements of a JSON array:

```sql
SELECT
  jsonb_build_array(title, length)
FROM
  film
ORDER BY
  title;
```

Output:

```text
          jsonb_build_array
--------------------------------------
 ["Academy Dinosaur", 86]
 ["Ace Goldfinger", 48]
 ["Adaptation Holes", 50]
 ["Affair Prejudice", 117]
...
```

## Summary

- Use the PostgreSQL `jsonb_build_array()` function to create a `JSONB` array from a variadic list of arguments.

---

## Related docs (JSON Functions)

- [Extracting JSON Data](https://neon.com/postgresql/json-functions/json-extract)
- [JSONB Operators](https://neon.com/postgresql/json-functions/jsonb-operators)
- [jsonb_agg](https://neon.com/postgresql/json-functions/jsonb_agg)
- [jsonb_array_elements](https://neon.com/postgresql/json-functions/jsonb_array_elements)
- [jsonb_array_elements_text](https://neon.com/postgresql/json-functions/jsonb_array_elements_text)
- [jsonb_array_length](https://neon.com/postgresql/json-functions/jsonb_array_length)
- [jsonb_build_object](https://neon.com/postgresql/json-functions/jsonb_build_object)
- [jsonb_each](https://neon.com/postgresql/json-functions/jsonb_each)
- [jsonb_each_text](https://neon.com/postgresql/json-functions/jsonb_each_text)
- [jsonb_extract_path](https://neon.com/postgresql/json-functions/jsonb_extract_path)
- [jsonb_extract_path_text](https://neon.com/postgresql/json-functions/jsonb_extract_path_text)
- [jsonb_insert](https://neon.com/postgresql/json-functions/jsonb_insert)
- [jsonb_object](https://neon.com/postgresql/json-functions/jsonb_object)
- [jsonb_object_agg](https://neon.com/postgresql/json-functions/jsonb_object_agg)
- [jsonb_object_keys](https://neon.com/postgresql/json-functions/jsonb_object_keys)
- [JSON Path](https://neon.com/postgresql/json-functions/json-path)
- [jsonb_path_exists](https://neon.com/postgresql/json-functions/jsonb_path_exists)
- [jsonb_path_query](https://neon.com/postgresql/json-functions/jsonb_path_query)
- [jsonb_path_query_array](https://neon.com/postgresql/json-functions/jsonb_path_query_array)
- [jsonb_path_query_first](https://neon.com/postgresql/json-functions/jsonb_path_query_first)
- [jsonb_pretty](https://neon.com/postgresql/json-functions/jsonb_pretty)
- [jsonb_set](https://neon.com/postgresql/json-functions/jsonb_set)
- [jsonb_strip_nulls](https://neon.com/postgresql/json-functions/jsonb_strip_nulls)
- [jsonb_to_record](https://neon.com/postgresql/json-functions/jsonb_to_record)
- [jsonb_populate_record](https://neon.com/postgresql/json-functions/jsonb_populate_record)
- [jsonb_populate_recordset](https://neon.com/postgresql/json-functions/jsonb_populate_recordset)
- [jsonb_typeof](https://neon.com/postgresql/json-functions/jsonb_typeof)
- [row_to_json](https://neon.com/postgresql/json-functions/row_to_json)
- [to_jsonb](https://neon.com/postgresql/json-functions/to_jsonb)
