Underscore.js _.unzip() Method

Beginner
5 min read
Updated: Nov 2026
4 examples
Array

Definition

The opposite of _.zip. Given an array of arrays, it returns new arrays: the first holds all first elements, the second all second elements, and so on (official Underscore docs). Stable Array helper — not deprecated.

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

Syntax

Call _.unzip. Start with this line.

Underscore
_.unzip(array)
CallWhat it does
_.unzip(array)Primary signature.
_.unzip(...)Call with the arguments your case needs.

Load Underscore with import _ from "underscore" (or the UMD CDN build) so these helpers are available as _.

Library declarations
Underscore
_.unzip(array)

Parameters

ParameterDescription
arrayRequired. Array of arrays (rows) to split by column

Return Value

Return ValueDescription
*New array of column arrays

Underscore.js Examples

Example 1 — Official Docs Unzip

Split stooge rows into name, age, and flag columns.

Underscore
_.unzip([
  ["moe", 30, true],
  ["larry", 40, false],
  ["curly", 50, false]
]);
// → [["moe", "larry", "curly"], [30, 40, 50], [true, false, false]]
Try It Yourself

How It Works

  1. Three rows. Each row is [name, age, flag].
  2. Column 0. Collect every name → first output array.
  3. Column 1 & 2. Ages and flags form the next two arrays.
  4. Shape. Three rows × three fields → three column arrays of length three.

Example 2 — Undo _.zip

_.unzip reverses a zip when every row has the same length.

Underscore
var names = ["moe", "larry", "curly"];
var ages = [30, 40, 50];

var zipped = _.zip(names, ages);
// → [["moe", 30], ["larry", 40], ["curly", 50]]

_.unzip(zipped);
// → [["moe", "larry", "curly"], [30, 40, 50]]
Try It Yourself

How It Works

  1. Zip first. Pair each name with its age into rows.
  2. Unzip next. Pull column 0 and column 1 back apart.
  3. Round-trip. You get the original column arrays again (same values and order).
  4. Rule. Even lengths make zip ↔ unzip clean inverses.

Example 3 — Transpose a Matrix

On a grid of rows, _.unzip (alias _.transpose) swaps rows and columns.

Underscore
var matrix = [
  [1, 2],
  [3, 4]
];

_.unzip(matrix);
// → [[1, 3], [2, 4]]

_.transpose(matrix);
// → [[1, 3], [2, 4]]  (same alias)
Try It Yourself

How It Works

  1. Rows. First row is [1, 2]; second is [3, 4].
  2. Columns become rows. [1, 3] and [2, 4].
  3. Alias. _.transpose is identical — clearer for matrix talk.
  4. Docs tip. Underscore highlights this as the matrix use of unzip.

Example 4 — Uneven Rows

Output width follows the longest row; shorter rows leave undefined.

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

How It Works

  1. Longest row. ["b", 2, true] has length 3 → three columns.
  2. Column 0. Every row has a first value → ["a","b","c"].
  3. Gaps. Missing slots become undefined (shown as null in some JSON.stringify outputs).
  4. Tip. Normalize row lengths first if you need clean columns without holes.

Browser & Runtime Support

_.unzip (alias _.transpose) ships with Underscore.js (1.x). It runs anywhere Underscore runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install underscore.

✓ Stable · Underscore 1.x

_.unzip()

Available in [email protected] (UMD / ESM). Works in evergreen browsers and current Node LTS when Underscore is loaded.

100% With Underscore 1.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 Underscore 1.x+

Bottom line: Safe for production once Underscore is on the page or in your bundle. Not a native browser API — load Underscore first. Prefer a pinned CDN version (e.g. [email protected]).

Frequently Asked Questions

_.unzip(array) is the opposite of _.zip. Given an array of arrays (rows), it returns new arrays: the first holds every first element, the second every second element, and so on.
Yes. _.transpose is an alias for _.unzip — both do the same thing.
_.zip merges several separate arrays by index into rows. _.unzip takes one array of rows and splits it back into columns. They are inverses.
One: a single array of arrays. Unlike _.zip, it is not variadic.
The number of output arrays matches the longest inner array. Missing positions from shorter rows become undefined.
Yes. On a matrix (array of row arrays), _.unzip swaps rows and columns — that is a transpose.

Next: _.object()

Convert key/value arrays (or pairs) into a plain object.

_.object() 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.

10 people found this page helpful