String to Array

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

0 items / 0 unique
Input Text
0 characters Ctrl+Enter to convert - Drag and drop .txt
Split the string

Regex patterns use JavaScript syntax. Visible-character mode keeps joined emoji and combining marks together.

Cleaning Options
Output
Output Format
JSON options
Customization
Output 0 unique Output
// Your converted output will appear here.
Equivalent code
Paste text and click Convert Text, or use Ctrl+Enter.
Your text stays private. All conversion happens locally in your browser using JavaScript. Nothing is uploaded to any server.

Copy the resulting array or matching JavaScript, Python, or PHP workflow, including the cleanup options you select.

How It Works

How to use the String to Array Converter

  1. 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.

  2. 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+.

  3. 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.

Examples

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(/[;|]/)

Notes

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.

FAQ

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.