Lodash _.unzip() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Array

Definition

Accepts an array of grouped elements (rows) and creates an array regrouping them into columns — the inverse of _.zip. Think: pivot spreadsheet rows into columns. Since Lodash 3.0.0.

Pass the required arguments shown below. Lodash Array helpers usually return a new value — check whether the source array is mutated.

Syntax

Call _.unzip on an array. Start with this line.

Lodash
_.unzip(array)
CallWhat it does
_.unzip(array)Primary signature.
_.unzip(array)Call with an array argument.

Prefer import unzip from "lodash/unzip" when you want a smaller bundle.

Library declarations
Lodash
_.unzip(array)

Parameters

ParameterDescription
arrayRequired. Array of grouped elements (rows)

Return Value

Return ValueDescription
*Array of column arrays

Lodash Examples

Example 1 — Official: Transpose Rows

Three fields per row become three column arrays.

Lodash
_.unzip([
  ["a", 1, true],
  ["b", 2, false]
]);
// → [["a", "b"], [1, 2], [true, false]]
Try It Yourself

How It Works

  1. Index 0. Collect "a", "b".
  2. Index 1. Collect 1, 2.
  3. Index 2. Collect true, false.
  4. Result. New array of three columns; source unchanged.

Example 2 — Round-Trip With _.zip

unzip undoes zip when every row has the same length.

Lodash
var zipped = _.zip(["a", "b"], [1, 2], [true, false]);
// → [["a", 1, true], ["b", 2, false]]

_.unzip(zipped);
// → [["a", "b"], [1, 2], [true, false]]
Try It Yourself

How It Works

  1. zip merges parallel arrays into rows.
  2. unzip splits those rows back into columns.
  3. Round-trip restores the original column lists.
  4. Docs pattern. Same idea as the official zip/unzip pair.

Example 3 — Names and Ages

Separate a list of [name, age] pairs into two columns.

Lodash
_.unzip([
  ["fred", 30],
  ["barney", 40]
]);
// → [["fred", "barney"], [30, 40]]
Try It Yourself

How It Works

  1. Column 0. All names.
  2. Column 1. All ages.
  3. Destructure. var cols = _.unzip(rows); var names = cols[0];
  4. Use. Handy before charting or separate API payloads.

Example 4 — Ragged Row Lengths

Shorter rows pad missing cells with undefined.

Lodash
_.unzip([
  ["a", 1],
  ["b"]
]);
// → [["a", "b"], [1, undefined]]
Try It Yourself

How It Works

  1. Width. Longest row has length 2 → two columns.
  2. Second row. No index 1 → push undefined.
  3. Check. Use === undefined, not JSON, to detect pads.
  4. Tip. Normalize rows first if pads are unwanted.

Example 5 — One Field Per Row

A list of single-item rows becomes one column array.

Lodash
_.unzip([["x"], ["y"], ["z"]]);
// → [["x", "y", "z"]]
Try It Yourself

How It Works

  1. Width 1. Only one column is created.
  2. Collect. Each row’s first (only) value.
  3. Result. Still nested: one array inside the outer array.
  4. Need a flat list? Use _.unzip(rows)[0] or _.map(rows, 0).

Browser & Runtime Support

_.unzip is a Lodash Array helper (since 3.0.0). It runs anywhere Lodash 4.x runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash.

✓ Stable · Lodash 3.0.0+

_.unzip()

Available in [email protected] full builds and the lodash/unzip modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.

100% With Lodash 4.x
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
_.unzip Lodash 3.0.0+

Bottom line: Safe for production once Lodash is loaded. Prefer import unzip from "lodash/unzip" for smaller builds.

Frequently Asked Questions

_.unzip(array) accepts an array of grouped elements (rows) and returns new arrays regrouped into columns — the inverse of _.zip.
No. It builds new column arrays. Element references inside those columns are reused.
zip takes separate arrays and merges them into rows. unzip takes rows and splits them back into columns.
Missing slots are filled with undefined so every output column reaches the longest row length.
Use _.unzipWith when you want to fold each column with an iteratee (sum, join, custom reducer) instead of returning the raw columns.
Use import unzip from "lodash/unzip" or require("lodash/unzip") for tree-shaking. Full build: import _ from "lodash" then _.unzip.

Next: _.unzipWith()

Unzip rows into columns, then fold each column with an iteratee.

_.unzipWith() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful