Lodash _.zip() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Array

Definition

Creates an array of grouped elements: the first group holds the first item from each array, the second group holds the second items, and so on. Inverse of _.unzip. Part of Lodash 4.x Array.

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

Syntax

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

Lodash
_.zip([arrays])
CallWhat it does
_.zip([arrays])Primary signature.
_.zip(array)Call with an array argument.

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

Library declarations
Lodash
_.zip([arrays])

Parameters

ParameterDescription
arraysOptional. Parallel columns to group

Return Value

Return ValueDescription
*New array of tuples

Lodash Examples

Example 1 — Official: Three Columns

Each index becomes one tuple across all inputs.

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

How It Works

  1. Index 0. Take first of each → ["a", 1, true].
  2. Index 1. Take second of each → ["b", 2, false].
  3. Length. Both inputs share length 2 → two tuples.
  4. Width. Three inputs → each tuple has three slots.

Example 2 — Two Parallel Columns

Classic name/score pairing into 2-tuples.

Lodash
_.zip(["ada", "bob"], [100, 85]);
// → [["ada", 100], ["bob", 85]]
Try It Yourself

How It Works

  1. Align. Same index in each array belongs together.
  2. First row. "ada" with 100.
  3. Second row. "bob" with 85.
  4. Use. Handy before mapping rows into objects or table cells.

Example 3 — Unequal Lengths

Missing slots are filled with undefined.

Lodash
_.zip([1, 2, 3], ["a"]);
// → [[1, "a"], [2, undefined], [3, undefined]]
Try It Yourself

How It Works

  1. Longest wins. Result length is 3 (from the first array).
  2. Index 0. Both values exist → [1, "a"].
  3. Pad. Indexes 1 and 2 have no letter → undefined.
  4. JSON tip. JSON.stringify turns those slots into null.

Example 4 — Round-Trip with _.unzip

When lengths match, unzip undoes zip.

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

How It Works

  1. Zip. Columns become [[1,"a"],[2,"b"]].
  2. Unzip. Rows pivot back into two columns.
  3. Restore. You get the original parallel arrays (new outer array).
  4. Caveat. Ragged padding can change shape after a round-trip.

Example 5 — Single Array & Empty Call

One column wraps each value; no arguments yield an empty result.

Lodash
_.zip(["x", "y", "z"]);
// → [["x"], ["y"], ["z"]]

_.zip();
// → []
Try It Yourself

How It Works

  1. One column. Each value becomes a one-item tuple.
  2. No args. Nothing to group → [].
  3. Still new. Result arrays are newly created.
  4. Safe. Neither case throws.

Browser & Runtime Support

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

✓ Stable · Lodash 4.x

_.zip()

Available in [email protected] full builds and the lodash/zip 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
_.zip Lodash 4.x+

Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import zip from "lodash/zip" for smaller builds. Not a native browser API — load Lodash first.

Frequently Asked Questions

_.zip(...arrays) creates an array of grouped elements: the first group holds every array’s first item, the second group holds every second item, and so on. Think columns → rows.
No. It returns a new array of tuples. Element references inside tuples are shared with the sources.
Lodash pads missing slots with undefined so each tuple matches the longest input length.
zip turns parallel column arrays into row tuples. unzip turns row tuples back into column arrays — they are inverses when shapes match.
When you want to combine aligned slots with a function (sum, join, merge) instead of keeping inner arrays.
Use import zip from "lodash/zip" or require("lodash/zip") for tree-shaking. Full build: import _ from "lodash" then _.zip.

Next: _.zipObject()

Turn parallel keys and values arrays into one plain object.

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