---
schema_version: "1"
id: 7466f5576a0745bcdc8b04a558e7736d3c94b5d5965e09415ef5b48af478cb16
title: "Handlebars Helper Function: flatten"
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud/handlebars/reference/objects/mcn-handlebars-reference-objects-flatten.md
canonical_url: https://developer.salesforce.com/docs/marketing/handlebars-for-marketing-cloud-next/references/mcn-handlebars-objects-references/mcn-handlebars-reference-objects-flatten.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 94fbb6c461f3da73d228574fe528a7b5c98132c1937744495141b3d43418b870
products:
  - Handlebars for Marketing Cloud Next
  - Marketing Cloud
---
# Handlebars Helper Function: flatten

Transforms a list of lists into a flat list. This function is useful for normalizing nested data structures in templates.

## Availability

This helper is available in the Winter ’26 release of Marketing Cloud Next.

## Syntax

```handlebars
{{flatten nestedList}}
```

## Parameters

| Parameter    | Type  | Description                             |
| ------------ | ----- | --------------------------------------- |
| `nestedList` | Array | Required. The list of lists to flatten. |

## Return Value

The function returns a new list containing all elements from the nested lists. If the input isn’t a list of lists, or if a parameter is missing or an element isn’t a list, the function throws an exception.

## Usage Examples

This example shows how to use the `flatten` function to flatten this example array.

```javascript
myArray = [[1, 2], [3, 4], [5]];
```

To flatten the array, use the `flatten` function, as shown in this example.

```handlebars
{{flatten myArray}}
```

The function returns `[1, 2, 3, 4, 5]`.
