Recursively flattens array until every element is non-array. Returns a new one-dimensional list. Part of Lodash 4.x Array (since 3.0.0).
Note: Native Array.prototype.flat(Infinity) (ES2019) is a close twin. Prefer Lodash when you already ship Lodash or need consistent imports on older targets.
Syntax
Call _.flattenDeep on an array. Start with this line.
Lodash
_.flattenDeep(array)
Call
What it does
_.flattenDeep(array)
Primary signature.
_.flattenDeep(array)
Call with an array argument.
Prefer import flattenDeep from "lodash/flattenDeep" when you want a smaller bundle.
Tip. Chain _.compact if you want falsy values removed.
Compatibility
Browser & Runtime Support
_.flattenDeep is a Lodash 4.x Array helper (since 3.0.0). It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash.
✓ Stable · Lodash 4.x
_.flattenDeep()
Available in [email protected] full builds and the lodash/flattenDeep modular import. Native Array.prototype.flat(Infinity) needs ES2019 (Chrome 69+, Firefox 62+, Safari 12+, Node 11+).
100%With Lodash 4.x
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
_.flattenDeepLodash 4.x+
Bottom line: Safe for production once Lodash is loaded. Prefer import flattenDeep from "lodash/flattenDeep" for smaller bundles. On modern-only targets, arr.flat(Infinity) is a fine native alternative.
Frequently Asked Questions
_.flattenDeep(array) recursively flattens nested arrays until every element is non-array. It returns a new one-dimensional array and does not mutate the source.
No. Lodash walks the nest and builds a brand-new flat array. The source structure is left unchanged.
_.flatten removes only one nesting level. _.flattenDeep keeps unwrapping until no element is an array.
_.flattenDepth(array, n) stops after n levels. flattenDeep is like unbounded depth — keep going until fully flat.
Array.prototype.flat(Infinity) is similar on ES2019+. Lodash helps with consistent imports and older environments without flat.
Use import flattenDeep from "lodash/flattenDeep" or require("lodash/flattenDeep") for tree-shaking friendly bundles. Full build: import _ from "lodash" then _.flattenDeep.