String to Array Converter
Split one string into array values by comma, custom delimiter, whitespace, regular expression, or visible character.
Split a string into array values
String splitter and code generator
// Your converted output will appear here.
Copy the resulting array or matching JavaScript, Python, or PHP workflow, including the cleanup options you select.
How to use the String to Array Converter
Paste or upload the source text
Enter the complete string you want to split, or upload a plain TXT file. Trimming and empty-value removal are enabled by default.
Choose how to split it
Choose comma, semicolon, new line, tab, a custom delimiter, Words for whitespace, Visible characters for grapheme clusters, or Regex for a JavaScript pattern such as [;|] or \d+.
Take the array or the code
Copy the generated array, or copy the complete JavaScript, Python, or PHP workflow underneath it. The code updates with your active cleanup settings.
String to Array Converter examples
Split a delimited string
Input
apple, banana, cherry, date
Output
[ "apple", "banana", "cherry", "date" ]
Comma mode splits on commas, and the default trimming step removes the padding after each comma.
Split on any run of whitespace
Input
alpha beta gamma delta
Output
[ "alpha", "beta", "gamma", "delta" ]
Word mode splits on runs of whitespace; the generated code also includes the selected trimming and empty-value cleanup.
Split with a regular expression
Input
id=41;name=ada|id=42;name=alan
Output
[ "id=41", "name=ada", "id=42", "name=alan" ]
Pattern [;|] — equivalent code: text.split(/[;|]/)
Working with string to array
Splitting is not the same as trimming
"a, b, c".split(",") gives you ["a", " b", " c"] — the space after each comma survives. That is the most common surprise when splitting strings by hand, and it produces values that look identical but never compare equal. This tool trims each value by default.
Empty values and consecutive delimiters
"a,,b".split(",") returns three values, the middle one empty. Whether that is a bug depends on the data: a missing CSV cell is meaningful, a double space between words is not. Remove empty values is on by default — turn it off when the gaps carry information.
When a regex beats a delimiter
Use Regex mode when the separator varies: [;,|] for mixed punctuation, \s*,\s* to absorb padding around commas, or \d+ to split on numbers. Patterns are validated with JavaScript syntax; the generated Python and PHP versions identify their language-specific regex behavior. For a ready-to-paste JavaScript array literal rather than split logic, use the JavaScript Array Converter.
String splitting versus list conversion
Use this page when one source string needs a configurable split rule. For a simple comma-delimited list, the Comma-Separated List to Array Converter offers a focused workflow; for one value per line, use the Line to Array Converter.
Popular text conversion tools
JavaScript Array Converter
Turn a list or string into a JavaScript array with const, let or var, single, double or template quotes, and automatic number and boolean detection.
Python List Converter
Convert pasted text into a Python list, tuple or set with correct True, False and None literals, single or double quotes, and numeric type detection.
Comma Separated List to Array Converter
Split a plain comma-separated list into an array, trimming the space after each comma and dropping empty values. For quoted CSV fields, use the CSV parser.
Line to Array Converter
Convert newline-separated text into an array. Handles CRLF and LF endings, blank lines and the trailing whitespace that copied columns and TXT files carry.
String to Array Converter FAQs
Split the string and take the result with you
Choose the split rule and cleanup you need, then copy either the array or the matching code. If your input is already one value per line, the Line to Array Converter provides a shorter path.