Converts string to snake_case — words lowercased and separated by _. Part of Lodash String since 3.0.0 (stable — not deprecated).
Note: Ideal for DB columns, JSON keys, and Python-style names. Same word-splitting family as _.camelCase and _.kebabCase — only the join style differs.
Syntax
Call _.snakeCase. Start with this line.
Lodash
_.snakeCase([string=''])
Call
What it does
_.snakeCase([string=''])
Primary signature.
_.snakeCase(string)
Transform or inspect a string.
Prefer import snakeCase from "lodash/snakeCase" when you want a smaller bundle.
Library declarations
Lodash
_.snakeCase([string=''])
Parameters
Parameter
Description
string
Optional. Input to convert; default ''
Return Value
Return Value
Description
*
New snake_case string
Lodash Examples
Example 1 — Official: Spaces
Title-style words become lowercase with underscores.
_.snakeCase is a Lodash String 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 3.0.0+
_.snakeCase()
Available in [email protected] full builds and the lodash/snakeCase modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.
100%With Lodash 3.0+
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
_.snakeCaseLodash 3.0.0+
Bottom line: Safe for production once Lodash is loaded. Prefer import snakeCase from "lodash/snakeCase" for smaller bundles. Use it to normalize labels into snake_case for APIs and databases.
Frequently Asked Questions
_.snakeCase([string='']) converts a string to snake_case: words lowercased and joined with underscores. Official: _.snakeCase('Foo Bar') → 'foo_bar'.
No. JavaScript strings are immutable. It always returns a new string.
snake_case uses underscores; kebab-case uses hyphens. Word-splitting rules are the same family of case helpers.
Spaces, hyphens, underscores, camelCase transitions, and most non-alphanumeric characters. Numbers often form their own word (foo2bar → foo_2_bar).
Empty string returns ''. Non-strings are coerced the Lodash way (null/undefined → empty string result from default '').
Use import snakeCase from "lodash/snakeCase" or require("lodash/snakeCase") for tree-shaking. Full build: import _ from "lodash" then _.snakeCase.