Creates an object with the same values as object and keys generated by running each own enumerable string key through iteratee. Part of Lodash Object since 3.8.0 (stable — not deprecated).
Warning: If two iteratee results collide, the later key silently overwrites the earlier one. Keep new keys unique.
Syntax
Call _.mapKeys. Start with this line.
Lodash
_.mapKeys(object, [iteratee])
Call
What it does
_.mapKeys(object, [iteratee])
Primary signature.
_.mapKeys(object)
Work with an object’s keys, values, or paths.
Prefer import mapKeys from "lodash/mapKeys" when you want a smaller bundle.
Library declarations
Lodash
_.mapKeys(object, [iteratee])
Parameters
Parameter
Description
object
Required. Source object to map
iteratee
Optional. Produces each new key; default _.identity
Return Value
Return Value
Description
*
New object (source not mutated)
Lodash Examples
Example 1 — Official: key + value
Combine each key with its value to build the new key name.
Pair. Chain both when you need to reshape both sides.
Pick. Choose the helper that matches what must change.
Compatibility
Browser & Runtime Support
_.mapKeys is a Lodash Object helper since 3.8.0. It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash.
✓ Stable · Lodash 3.8.0+
_.mapKeys()
Available in [email protected] full builds and the lodash/mapKeys modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.
100%With Lodash 3.8+
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
_.mapKeysLodash 3.8.0+
Bottom line: Safe for production once Lodash is loaded. Prefer import mapKeys from "lodash/mapKeys" for smaller bundles. Use it to rename or normalize object keys without mutating the source.
Frequently Asked Questions
_.mapKeys(object, [iteratee]) creates a new object with the same values and keys produced by iteratee. Official: _.mapKeys({a:1,b:2}, (v,k) => k+v) → {a1:1, b2:2}.
It is called as (value, key, object) for each own enumerable string-keyed property. Whatever it returns becomes the new key.
No. It always returns a new object. The source is left unchanged.
Last write wins silently. The later property overwrites the earlier one at that key. Keep transformed keys unique.
mapKeys rewrites keys and keeps values. mapValues keeps keys and rewrites values.
Use import mapKeys from "lodash/mapKeys" or require("lodash/mapKeys") for tree-shaking. Full build: import _ from "lodash" then _.mapKeys.