JavaScript split Is Not a Function: Causes and Fixes

Errors & fixes · Updated November 22, 2026

split() is a JavaScript string method, so “split is not a function” usually means your code is calling it on a value that is not a string—or that the value’s split property is not callable. Check the value immediately before the call, then either correct its source or convert it deliberately to a string.

What the error means

JavaScript strings have a split() method that divides a string into parts and returns an array. For example, "red,blue".split(",") returns ["red", "blue"]. Numbers, arrays, ordinary objects, and booleans do not have that string method. Calling split() on one of those values can produce a TypeError such as value.split is not a function.

The error identifies a mismatch between the operation and the value at runtime; it does not necessarily mean the text in your source code is misspelled. A variable that was expected to hold text may instead contain a number, an array, an object, or a value returned by a different part of the program. The precise error wording can vary between JavaScript engines.

For example, 42.split("") is not a useful way to split the number 42: numbers do not expose the string method. Convert it explicitly if the intended result is the individual characters of its decimal representation: String(42).split("") produces ["4", "2"].

Find the value that is not a string

Start by inspecting the receiver—the value to the left of .split—at the exact line that fails. Logging its value and type often reveals that an assumption about input data is wrong:

console.log(value, typeof value);

For objects and arrays, typeof alone is not very descriptive: both report "object", and typeof null also reports "object". You can additionally use Array.isArray(value) and, when useful, value === null. A browser debugger or Node.js inspector can show nested object properties more clearly than a basic log.

  • If the value is a number, decide whether converting it to text is appropriate.
  • If it is an array, check whether it is already split into items or whether a particular string inside it should be split.
  • If it is an object, inspect the property that is supposed to contain the text.
  • If it is null or undefined, trace where that missing value was expected to be assigned.

Logging before the failing line matters. A log elsewhere may show an earlier value, before an asynchronous response, state update, or reassignment changed the variable.

Common causes and examples

A number was supplied: Values from a calculation or numeric form field may be numbers, even if the program later treats them as text. Convert only when textual splitting is actually the goal: String(count).split(""). If the goal is numeric processing, use arithmetic rather than converting and splitting.

An array was supplied: An array is already a collection, but it does not have the string method split(). For a comma-separated string, split first; for an existing array, use array operations such as map() or filter(). To split every string in an array, use values.map(item => item.split(",")), provided every item is a string.

The wrong object property was used: Suppose an API response is { name: "Rae" }, but the code calls response.split(","). The response is an object; the text is in response.name. Check the actual response shape rather than assuming the whole result is a string.

A property is missing: Calling record.tags.split(",") fails if tags is absent or has a non-string value. A missing property may cause a different TypeError, such as an attempt to read split from undefined. That related message points to a nullish receiver, while “is not a function” generally means a property was found but was not callable.

The method name was overwritten: An object can have a property named split that replaces or hides the expected method, such as text.split = 3. In that case, even a string-like object may not behave as expected. Inspect value.split as well as value if the receiver appears to be text.

Choose a safe fix

The right fix depends on what the value is supposed to represent. Do not automatically turn every unexpected value into text: stringifying an object can yield [object Object], which is rarely a meaningful list of fields. Choose an approach that matches the input contract.

  • Require a string: Validate the input and report or handle invalid data. A strict check is if (typeof value !== "string") { throw new TypeError("Expected a string"); } followed by value.split(",").
  • Convert a value intentionally: Use String(value).split(",") when the application specifically wants the value’s textual representation. Remember that String(null) is "null" and String(undefined) is "undefined".
  • Use a fallback for missing input: If missing values should mean an empty string, use (value ?? "").split(","). This handles only null and undefined; it does not convert numbers or objects into strings.
  • Handle more than one accepted type: Branch on the type and define what each case means instead of relying on accidental coercion.

For example, when a field may be missing but otherwise must be text, a clear guard is easier to maintain than a broad conversion: const parts = typeof value === "string" ? value.split(",") : [];. This treats every non-string as an empty list, so use it only if that is the intended behavior. If invalid input should be visible, throw an error or show a validation message instead.

How split() works

The method accepts a separator and an optional limit. The separator can be a string or a regular expression. A string separator matches that sequence of characters; a regular expression can describe a pattern. The optional limit restricts the number of items returned.

  • "one,two,three".split(",") returns ["one", "two", "three"].
  • "a b".split(/s+/) splits on one or more whitespace characters, producing ["a", "b"].
  • "a,b,c".split(",", 2) returns ["a", "b"].
  • "hello".split("") returns an array of string units, in this case ["h", "e", "l", "l", "o"].

An empty separator is not the same as omitting the separator. With no argument, split() returns an array containing the whole original string; with an empty string separator, it divides the string into UTF-16 code units. That distinction matters for emoji and some other Unicode characters: a visible symbol can consist of multiple code units, so splitting on an empty string may break it apart. For code points, Array.from(text) is often more suitable, while complete user-perceived characters may require a grapheme-aware approach such as Intl.Segmenter.

Input from forms, APIs, and JSON

Values do not always arrive in the type a developer expects. Browser form controls commonly expose their current contents through a string-valued value property, but code may later parse that text into a number. JSON parsing can produce strings, numbers, booleans, arrays, objects, or null, depending on the response. A property omitted from a JSON object evaluates to undefined.

For example, a server might return { "labels": ["urgent", "review"] }. Since labels is already an array, calling data.labels.split(",") is a mismatch. By contrast, a response containing { "labels": "urgent,review" } does provide a string to split. Confirm the documented data shape and validate external data at the boundary where it enters your application.

For query parameters, form values, or user-entered text, consider whether leading or trailing spaces should be removed before splitting, whether empty pieces are meaningful, and what should happen for an empty input. For example, "a,,b".split(",") retains an empty item between the commas. Silently filtering empty strings may be right for one task and wrong for another, so make that decision explicit.

Debugging checklist

  1. Read the complete error and identify the exact expression before .split.
  2. Log or inspect that value immediately before the call, including its type and whether it is nullish.
  3. Trace the value back to its source: a function argument, parsed response, form field, or earlier transformation.
  4. Compare the runtime value with the intended data shape, including whether a string is nested in an object or array.
  5. Choose validation, conversion, a fallback, or an array operation according to the intended behavior.
  6. Test the normal case and edge cases such as missing data, an empty string, a number, and an unexpected object.

If the failure appears only sometimes, inspect timing and control flow too. For example, a property may be populated after a request completes, or one branch of a conditional may assign a string while another assigns an array. Fixing the source of inconsistent data is generally more reliable than adding a conversion at the final call site.

Frequently Asked Questions

Is split() a JavaScript function?
split() is a method provided by strings through String.prototype. You normally call it on a string, such as "x,y".split(","); it is not a standalone global function.

How do I fix “split is not a function”?
Check the value before .split(). If it should be text, correct the data source or convert it intentionally with String(value). If it is an array or object, use the appropriate operation or access the string property instead.

Why does “Cannot read properties of undefined” mention split?
That usually means the receiver is undefined, often because a property is missing or a value has not been assigned. Check the object path and input data. It is related to, but distinct from, finding a non-callable split property.

Can I call split() on an array?
No. Arrays do not have the string method split(). They are already collections; use array methods, or call split() on a particular string element if that is what you intend.

Does split() change the original string?
No. Strings are immutable, and split() returns a new array of pieces. It does not modify the original string.

What does split("") do?
It separates a string into UTF-16 code units, not necessarily complete visible characters. It works as expected for simple basic Latin text, but can divide some Unicode symbols; use a Unicode-aware method when character integrity matters.

Related

Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.

More in Errors & fixes

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.