Favorites

JavaScript String.prototype.split() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
String.prototype.split()
JavaScript String Instance methodThis method is supported by all modern browsers.
Updated 28th November 2026

The split() method divides a string into an array of pieces, splitting it wherever a separator appears.

Description

The split() method divides a string into an array of substrings wherever the separator appears. The separator can be a string or a regular expression; with '', the string is split into UTF-16 code units. It's the opposite of Array.prototype.join().

Splitting into characters with '' breaks emoji apart; [...str] or Array.from(str) keeps code points together.

When the separator is a regular expression with capture groups, the captured text is included in the result, which can be used to keep the separators. Splitting an empty string with a non-empty separator returns [''], not an empty array, so filter out empty strings if your data might be empty. For splitting text into words or sentences in any language, Intl.Segmenter is more reliable.

Syntax

string.split(separator)
string.split(separator, limit)

Parameters

  • separatorThe string or regular expression to split at. If left out, the result is an array with the whole string.
  • limitOptional. The maximum number of pieces to return.

Return Value

An array of strings.

Example

console.log('red,green,blue'.split(','));
console.log('a  b   c'.split(/\s+/));
console.log('one two three'.split(' ', 2));
console.log('hi'.split(''));

Browser Support

The following information will show you the current browser support for the String.prototype.split() method. Hover over a browser icon to see the version that first introduced support for this method.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee