Lodash _.split() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
String

Definition

Splits string by separator and returns an array of substrings. Part of Lodash String since 3.1.0 (stable — not deprecated).

Note: Closely mirrors native String.prototype.split, but coerces null/undefined to '' first so you avoid TypeErrors.

Syntax

Call _.split. Start with this line.

Lodash
_.split([string=''], separator, [limit])
CallWhat it does
_.split([string=''], separator, [limit])Primary signature.
_.split(string)Transform or inspect a string.

Prefer import split from "lodash/split" when you want a smaller bundle.

Library declarations
Lodash
_.split([string=''], separator, [limit])

Parameters

ParameterDescription
stringOptional. Input to split; default ''
separatorOptional. String or RegExp delimiter
limitOptional. Max number of segments to return

Return Value

Return ValueDescription
*Array of substrings

Lodash Examples

Example 1 — Official: Separator + Limit

Split on - but keep only the first two segments.

Lodash
_.split('a-b-c', '-', 2);
// → ['a', 'b']
Try It Yourself

How It Works

  1. Separator. Split wherever - appears.
  2. Parts. Would be a, b, c.
  3. Limit 2. Keep only the first two.
  4. Result. ['a', 'b'] — no leftover third chunk.

Example 2 — Full Split (No Limit)

Omit limit to get every segment.

Lodash
_.split('a-b-c', '-');
// → ['a', 'b', 'c']
Try It Yourself

How It Works

  1. Two dashes. Three pieces.
  2. No limit. All segments returned.
  3. Order. Left to right.
  4. Use. Path / CSV-style tokenizing.

Example 3 — Regex Separator

Split on digit runs with a regular expression.

Lodash
_.split('a1b2c', /\d+/);
// → ['a', 'b', 'c']
Try It Yourself

How It Works

  1. Pattern. /\d+/ matches one or more digits.
  2. Cuts. Removes 1 and 2 as separators.
  3. Keep. Letter chunks a, b, c.
  4. Power. Use regex when the delimiter varies.

Example 4 — Split Into Characters

Empty-string separator yields one character per element.

Lodash
_.split('abc', '');
// → ['a', 'b', 'c']
Try It Yourself

How It Works

  1. Empty sep. Split between every character.
  2. Three chars. Three array items.
  3. Note. Surrogate pairs / emoji may need care in JS generally.
  4. Alt. For word tokens, prefer _.words.

Example 5 — Null-Safe Input

Nullish values are coerced — no TypeError.

Lodash
_.split(null, '-');
// → ['']

_.split(undefined, '-');
// → ['']
Try It Yourself

How It Works

  1. Coerce. null/undefined → ''.
  2. Split. Empty string with a separator → [''].
  3. Safe. Native null.split would throw.
  4. Habit. Handy in pipelines with optional fields.

Browser & Runtime Support

_.split is a Lodash String helper since 3.1.0. It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash.

✓ Stable · Lodash 3.1.0+

_.split()

Available in [email protected] full builds and the lodash/split modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.

100% With Lodash 3.1+
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
_.split Lodash 3.1.0+

Bottom line: Safe for production once Lodash is loaded. Prefer import split from "lodash/split" for smaller bundles. Use it for null-safe splits with an optional limit.

Frequently Asked Questions

_.split([string=''], separator, [limit]) splits string by separator into an array of substrings. Official: _.split('a-b-c', '-', 2) → ['a','b'].
Behavior is very similar. Lodash coerces null/undefined to '' first, so _.split(null, '-') returns [""] instead of throwing.
It caps how many segments are returned. With limit 2 on 'a-b-c', you get ['a','b'] — the rest is not included as a leftover chunk in Lodash’s documented example.
Yes. Example: _.split('a1b2c', /\d+/) → ['a','b','c'].
Use an empty string separator: _.split('abc', '') → ['a','b','c'].
Use import split from "lodash/split" or require("lodash/split") for tree-shaking. Full build: import _ from "lodash" then _.split.

Next: _.startCase()

Convert a string to Start Case for human-readable titles.

_.startCase() tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful