# flatten() in Jira Automation: syntax and examples

URL: https://goingstellar.ro/reference/smart-values/list-flatten/

flatten() merges a nested list into a one-dimensional list. A list of lists appears when a text function such as split() runs on every item of a list, or when a webhook delivers nested data.

## Syntax

```
{{list.flatten()}}
```

## Works on

- Fields: a list whose items are themselves lists, such as comment bodies after split().
- Returns: one flat list.

## Examples

```
{{issue.comments.body.split(" ")}}
```

Split every comment into words. The result is one list of words per comment.

Result:

```
[First, comment, from, QA], [Second, comment:, fixed, in, build, 42]
```

Run on Jira Cloud on 29 Nov 2026.

```
{{issue.comments.body.split(" ").flatten()}}
```

Merge the two word lists into one.

Result:

```
First, comment, from, QA, Second, comment:, fixed, in, build, 42
```

Run on Jira Cloud on 29 Nov 2026.

```
{{issue.comments.body.split(" ").size}}
```

Without flatten the size counts the inner lists, one per comment.

Result:

```
2
```

Run on Jira Cloud on 29 Nov 2026.

```
{{issue.comments.body.split(" ").flatten().size}}
```

After flatten the size counts every word of every comment.

Result:

```
10
```

Run on Jira Cloud on 29 Nov 2026.

```
{{issue.comments.body.split(" ").flatten().join("_")}}
```

Chain join() to print all the words of all comments as one token.

Result:

```
First_comment_from_QA_Second_comment:_fixed_in_build_42
```

Run on Jira Cloud on 29 Nov 2026.

## Pitfalls

- The Atlassian example reads data from `webhookData`. In a rule with a manual trigger there is no webhook data, and the smart value renders an empty string instead of the numbers (checked on Jira Cloud, November 2026). It only returns data in a rule started by an incoming webhook.
- A list printed without flatten shows its inner lists in square brackets. That is the signal that a text function ran on every item and that you need flatten() before counting or joining.
- On a list that is already flat, such as the labels, flatten() changes nothing.

## Related

- [distinct](https://goingstellar.ro/reference/smart-values/list-distinct/)
- [join()](https://goingstellar.ro/reference/smart-values/list-join/)
- [size and isEmpty on lists](https://goingstellar.ro/reference/smart-values/list-size-isempty/)
- [split()](https://goingstellar.ro/reference/smart-values/split/)
- [{{issue.comments}}](https://goingstellar.ro/reference/smart-values/issue-comments/)

## Sources

- [Jira smart values: lists (Atlassian Support)](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/)
- [Jira smart values: JSON functions (Atlassian Support)](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-json-functions/)

