Converts value to an array. Part of Lodash Lang (stable — not deprecated). Note: not the same as _.castArray — toArray expands array-likes and objects; castArray only wraps.
Pass the value you want to inspect or convert. Read the return type carefully before you use the result.
Syntax
Call _.toArray. Start with this line.
Lodash
_.toArray(value)
Call
What it does
_.toArray(value)
Primary signature.
Prefer import toArray from "lodash/toArray" when you want a smaller bundle.
Library declarations
Lodash
_.toArray(value)
Parameters
Parameter
Description
value
Required. Value to convert
Return Value
Return Value
Description
*
New Array (always a fresh array for truthy inputs that convert)
Pick expand. Character lists, object values, iterables → toArray.
Pick wrap. “Always give me an array API” for a scalar → castArray.
Compatibility
Browser & Runtime Support
_.toArray is a Lodash Lang 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 alternatives include Array.from, Object.values, and the spread operator, each covering part of the same job.
✓ Stable · Lodash 4.x
_.toArray()
Available in [email protected] full builds and the lodash/toArray 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
_.toArrayLodash 4.x
Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import toArray from "lodash/toArray" for smaller builds. For modern engines, Array.from / Object.values / [...iterable] are close cousins.
Frequently Asked Questions
_.toArray(value) converts value into a new array — object values, string characters, Map entries, Set values, or a shallow copy of array-likes. Falsy values become [].
castArray wraps a non-array as [value] (or returns the same array). toArray expands array-likes and objects into element lists — e.g. 'abc' becomes ['a','b','c'], not ['abc'].
Falsy inputs short-circuit to an empty array. That matches the official Lodash example.
Yes. Strings are split by Unicode code points (like the spread operator), so multi-byte characters stay intact instead of breaking into surrogates.
Maps become entry pairs [[key, value], …]. Sets become their values array. Both rely on the iterable protocol.
Use import toArray from "lodash/toArray" or require("lodash/toArray") for tree-shaking friendly bundles. Full build: import _ from "lodash" then _.toArray.