---
title: chunks
categories: |
filters
version: 0.104.0
filters: |
Divide a list, table or binary input into chunks of `chunk_size`.
usage: |
Divide a list, table or binary input into chunks of `chunk_size`.
editLink: false
contributors: false
---
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->
# `chunks` for [filters](/commands/categories/filters.md)
<div class='command-title'>Divide a list, table or binary input into chunks of `chunk_size`.</div>
## Signature
```> chunks {flags} (chunk_size)```
## Parameters
- `chunk_size`: The size of each chunk.
## Input/output types:
| input | output |
| --------- | --------------- |
| binary | list\<binary\> |
| list\<any\> | list\<list\<any\>\> |
| table | list\<table\> |
## Examples
Chunk a list into pairs
```nu
> [1 2 3 4] | chunks 2
╭───┬───────────╮
│ 0 │ ╭───┬───╮ │
│ │ │ 0 │ 1 │ │
│ │ │ 1 │ 2 │ │
│ │ ╰───┴───╯ │
│ 1 │ ╭───┬───╮ │
│ │ │ 0 │ 3 │ │
│ │ │ 1 │ 4 │ │
│ │ ╰───┴───╯ │
╰───┴───────────╯
```
Chunk the rows of a table into triplets
```nu
> [[foo bar]; [0 1] [2 3] [4 5] [6 7] [8 9]] | chunks 3
╭───┬───────────────────╮
│ 0 │ ╭───┬─────┬─────╮ │
│ │ │ # │ foo │ bar │ │
│ │ ├───┼─────┼─────┤ │
│ │ │ 0 │ 0 │ 1 │ │
│ │ │ 1 │ 2 │ 3 │ │
│ │ │ 2 │ 4 │ 5 │ │
│ │ ╰───┴─────┴─────╯ │
│ 1 │ ╭───┬─────┬─────╮ │
│ │ │ # │ foo │ bar │ │
│ │ ├───┼─────┼─────┤ │
│ │ │ 0 │ 6 │ 7 │ │
│ │ │ 1 │ 8 │ 9 │ │
│ │ ╰───┴─────┴─────╯ │
╰───┴───────────────────╯
```
Chunk the bytes of a binary into triplets
```nu
> 0x[11 22 33 44 55 66 77 88] | chunks 3
╭───┬───────────────╮
│ 0 │ [17, 34, 51] │
│ 1 │ [68, 85, 102] │
│ 2 │ [119, 136] │
╰───┴───────────────╯
```
## Notes
This command will error if `chunk_size` is negative or zero.