Creates an array of the own enumerable property names of object. Part of Lodash Object (stable — not deprecated). Non-object values are coerced to objects. Inherited prototype keys are skipped — use _.keysIn for those. Note: iteration order is not guaranteed by the official docs.
Pass the object and path or keys shown below. Check whether the helper mutates or returns a new object.
Syntax
Call _.keys. Start with this line.
Lodash
_.keys(object)
Call
What it does
_.keys(object)
Primary signature.
Prefer import keys from "lodash/keys" when you want a smaller bundle.
Library declarations
Lodash
_.keys(object)
Parameters
Parameter
Description
object
Required. Object to query (non-objects are coerced)
Number. Coerced object has no enumerable own keys → [].
Contrast.Object.keys(null) throws a TypeError.
Use. Safer default for uncertain API payloads.
Compatibility
Browser & Runtime Support
_.keys is a Lodash Object helper available in 4.x (and earlier builds). It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Native Object.keys is similar for plain objects; Lodash adds non-object coercion and null-safe empty arrays.
✓ Stable · Lodash 4.x
_.keys()
Available in [email protected] full builds and the lodash/keys 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
_.keysLodash 4.x
Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import keys from "lodash/keys" for smaller builds. Use keysIn when inherited keys should be included.
Frequently Asked Questions
_.keys(object) creates an array of the own enumerable property names of object. Official: _.keys(new Foo) → ['a', 'b'] (prototype key c is skipped).
_.keys returns only own enumerable string keys. _.keysIn also includes inherited enumerable string keys from the prototype chain.
For ordinary objects they are very similar. Lodash coerces non-objects and is friendlier with null/undefined (empty array instead of a throw).
Strings are coerced to objects. Character indexes become own enumerable keys — official docs show exactly that.
No. It returns string-keyed property names only.
Use import keys from "lodash/keys" or require("lodash/keys") so bundlers can tree-shake. Full build: import _ from "lodash" then _.keys.