> For the complete documentation index, see [llms.txt](https://mikefarah.gitbook.io/yq/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mikefarah.gitbook.io/yq/operators/collect-into-array.md).

# Collect into Array

This creates an array using the expression between the square brackets.

## Collect empty

Running

```bash
yq --null-input '[]'
```

will output

```yaml
[]
```

## Collect single

Running

```bash
yq --null-input '["cat"]'
```

will output

```yaml
- cat
```

## Collect many

Given a sample.yml file of:

```yaml
a: cat
b: dog
```

then

```bash
yq '[.a, .b]' sample.yml
```

will output

```yaml
- cat
- dog
```
