Lodash _.zipObjectDeep() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Array

Definition

Like _.zipObject, but each prop is a property path (dots and brackets). Lodash builds nested objects/arrays — same path rules as _.set. 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 _.zipObjectDeep on an array. Start with this line.

Lodash
_.zipObjectDeep([props=[]], [values=[]])
CallWhat it does
_.zipObjectDeep([props=[]], [values=[]])Primary signature.
_.zipObjectDeep(array)Call with an array argument.

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

Library declarations
Lodash
_.zipObjectDeep([props=[]], [values=[]])

Parameters

ParameterDescription
propsOptional. Property paths; default []
valuesOptional. Matching values; default []

Return Value

Return ValueDescription
*New nested object

Lodash Examples

Example 1 — Official: Nested Array Paths

Dots and brackets combine into one nested tree.

Lodash
_.zipObjectDeep(["a.b[0].c", "a.b[1].d"], [1, 2]);
// → { a: { b: [{ c: 1 }, { d: 2 }] } }
Try It Yourself

How It Works

  1. Path 1. a.b[0].c creates a.b as an array and sets index 0.
  2. Path 2. a.b[1].d fills index 1 on the same array.
  3. Merge. Both paths share the a.b parent.
  4. Values. Leaves get 1 and 2.

Example 2 — Dotted Paths Under One Parent

Flat env-style keys collapse into one nested record.

Lodash
_.zipObjectDeep(["user.name", "user.age"], ["Ada", 42]);
// → { user: { name: "Ada", age: 42 } }
Try It Yourself

How It Works

  1. Shared prefix. Both paths start with user.
  2. First set. user.name = "Ada".
  3. Second set. user.age = 42 on the same object.
  4. Result. One user object with two fields.

Example 3 — Bracket Indices Build Arrays

Numeric brackets allocate array elements.

Lodash
_.zipObjectDeep(["items[0].sku", "items[1].sku"], ["A1", "B2"]);
// → { items: [{ sku: "A1" }, { sku: "B2" }] }
Try It Yourself

How It Works

  1. Array parent. items becomes an array.
  2. Index 0. First object gets sku: "A1".
  3. Index 1. Second object gets sku: "B2".
  4. Use. Handy for spreadsheet-style parallel columns.

Example 4 — Deep vs Shallow zipObject

Same strings, different structures.

Lodash
_.zipObject(["a.b", "a.c"], [1, 2]);
// → { "a.b": 1, "a.c": 2 }

_.zipObjectDeep(["a.b", "a.c"], [1, 2]);
// → { a: { b: 1, c: 2 } }
Try It Yourself

How It Works

  1. Shallow. zipObject keeps "a.b" as one key name.
  2. Deep. zipObjectDeep splits on the dot.
  3. Nest. Both deep paths share parent a.
  4. Pick. Use shallow when dots must stay in the key string.

Example 5 — Missing Values

Short value lists still create the path; the leaf is undefined.

Lodash
_.zipObjectDeep(["user.name", "user.age"], ["Ada"]);
// → { user: { name: "Ada", age: undefined } }

_.zipObjectDeep([], [1, 2]);
// → {}
Try It Yourself

How It Works

  1. First path. user.name gets "Ada".
  2. Second path. No value → leaf is undefined.
  3. JSON tip. JSON.stringify omits undefined leaves.
  4. Empty props. No paths → empty object.

Browser & Runtime Support

_.zipObjectDeep 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

_.zipObjectDeep()

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

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

Frequently Asked Questions

_.zipObjectDeep(props, values) builds a nested object by pairing each property path in props with the value at the same index. Paths use dots and brackets, like _.set.
No. It returns a new nested object. The props and values arrays stay unchanged.
zipObject treats each prop as one literal key (so "a.b" stays flat). zipObjectDeep parses paths and creates nested objects or arrays.
Use brackets such as items[0].sku. Lodash allocates arrays at numeric segments.
Later assignments win. Shared prefixes merge into the same parent until a later value replaces an intermediate node.
Use import zipObjectDeep from "lodash/zipObjectDeep" or require("lodash/zipObjectDeep") for tree-shaking. Full build: import _ from "lodash" then _.zipObjectDeep.

Next: _.zipWith()

Combine aligned elements from parallel arrays with a custom iteratee.

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