Runs each element through an iteratee, then flattens the mapped results one level into a new array. Same idea as _.map + _.flatten. Part of Lodash 4.x Collection.
Pass the required arguments shown below. Lodash Collection helpers usually return a new value — check whether the source is mutated.
Syntax
Call _.flatMap on a collection. Start with this line.
Lodash
_.flatMap(collection, [iteratee=_.identity])
Call
What it does
_.flatMap(collection, [iteratee=_.identity])
Primary signature.
_.flatMap(collection)
Call with a collection argument.
Prefer import flatMap from "lodash/flatMap" when you want a smaller bundle.
Iteratee. Returns [[n, n]] — an array wrapping another array.
flatMap. Removes only the outer wrapper → still nested pairs.
flatMapDeep. Recurses until values are flat.
Rule. Default depth is one — match the helper to your nesting.
Compatibility
Browser & Runtime Support
_.flatMap is a Lodash 4.x Collection helper. It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Native Array.prototype.flatMap is ES2019 and separate.
✓ Stable · Lodash 4.x
_.flatMap()
Available in [email protected] full builds and the lodash/flatMap modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.
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
_.flatMapLodash 4.x+
Bottom line: Safe for production once Lodash is loaded. Prefer import flatMap from "lodash/flatMap" for smaller builds. For array-only modern JS without Lodash, see native Array.flatMap.
Frequently Asked Questions
_.flatMap(collection, iteratee) maps each element through iteratee, then flattens the results one level into a new array. It is like _.map followed by _.flatten.
No. It returns a new array. The source collection is left unchanged.
Exactly one level. Deeper nesting stays nested. Use _.flatMapDeep for full recursion or _.flatMapDepth for a chosen depth.
_.map keeps one output slot per input (arrays stay nested). _.flatMap concatenates array results into one flat list.
Scalars and objects are treated as single items — they appear once in the result, not wrapped.
Native Array.prototype.flatMap (ES2019) is fine for modern array-only code. Prefer _.flatMap for object collections, Lodash iteratee shorthands, or when Lodash is already in the project.