# Unzip an array of arrays

Regroup the n-th item of every array into the n-th output array.

Canonical: https://1loc.dev/array/unzip-an-array-of-arrays/
Version: 1.0.0
Runtime: JavaScript · Node.js 22 / modern browsers
Verification: Local fixtures; no external services
Updated: 2026-10-28

## Implementation

```javascript
function unzip(arrays) { return Array.from({ length: Math.max(0, ...arrays.map(array => array.length)) }, (_, i) => arrays.filter(array => i < array.length).map(array => array[i])); }
```

## Input

```json
[
  [
    "ana@example.com",
    "delivered"
  ],
  [
    "rui@example.com",
    "deferred"
  ]
]
```

## Expected output

```json
[
  [
    "ana@example.com",
    "rui@example.com"
  ],
  [
    "delivered",
    "deferred"
  ]
]
```

## Edge case

Input:
```json
[]
```
Output:
```json
[]
```

## Limits

- Shorter arrays simply contribute fewer items.
- The inverse of Zip multiple arrays.

The lab validates types and size before calling this function. Add equivalent validation at your own trust boundary.

## Source and license

Original: https://github.com/phuocng/1loc/blob/14b481cf60dff1620ab1bb99a43b1f68068cdd9b/contents/unzip-an-array-of-arrays.mdx
Author: Nguyen Huu Phuoc and original contributors
Contributors: See original repository history
Source commit: 14b481cf60dff1620ab1bb99a43b1f68068cdd9b
Copyright (c) 2020 phuoc-ng
License: MIT — https://1loc.dev/licenses/
Maintainer: Oveyon
Modifications: Builds each column with filter and map instead of pushing into accumulators; handles an empty input. Original MDX retained as inert source evidence.
