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
{{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.
myArray = [[1, 2], [3, 4], [5]];
To flatten the array, use the flatten function, as shown in this example.
{{flatten myArray}}
The function returns [1, 2, 3, 4, 5].