String to Array Converter

Split any delimited string into a JSON or JavaScript array with trim, dedupe, and formatting options. Free, browser-based, and built for everyday development tasks.

Browser-basedFree foreverNo signup required3 min read

Quick Answer

The String to Array Converter splits delimited text into an array — by comma, newline, space, tab, semicolon, or a custom delimiter — with trim, empty-removal, and dedupe options, output as JSON, a JS literal, lines, or quoted CSV.

About String to Array Converter

Turning a blob of delimited text into a clean array is a constant micro-task: a comma-separated ID list from a spreadsheet that needs to become a JSON array for an API call, a column of values that should be a JavaScript literal, tags typed with inconsistent spacing that need deduplicating. This converter handles the split, cleanup, and output formatting in one pass, showing the item count so you can sanity-check the result before copying.

Why use this tool?

  • API payloads — convert spreadsheet columns or CSV fragments into JSON arrays for request bodies
  • Code literals — produce ready-to-paste JavaScript array syntax from any delimited list
  • SQL IN clauses — output quoted CSV for WHERE id IN (...) queries
  • List cleanup — trim whitespace, drop blanks, and deduplicate in a single conversion
  • Format switching — go from one-per-line to comma-separated (or back) without a regex

How it works

  1. 1Paste your delimited text into the input
  2. 2Choose the delimiter to split on — or "Custom" for anything else (like | or ::)
  3. 3Toggle trim, remove-empty, and dedupe options to clean the items
  4. 4Pick the output format and click Convert — the item count and formatted array appear instantly

Common mistakes to avoid

  • Values containing the delimiter — splitting "Smith, John" on commas produces two items; if your values can contain commas, use a different delimiter or a real CSV parser
  • Forgetting to trim — " b" and "b" are different strings; without trimming, dedupe and downstream comparisons silently miss matches
  • Quote style mismatch — JSON requires double quotes while most JS style guides prefer single; pick the output format matching the destination instead of find-replacing quotes afterwards
  • Windows line endings — pasted text may contain \r\n; this tool splits on both, but hand-rolled split("\n") code leaves trailing \r characters on every item

Pro tip

The quoted-CSV output drops straight into SQL: WHERE email IN (<paste>). For the reverse direction — array back to plain text — convert with "One per line" and you have spreadsheet-ready data.

Frequently Asked Questions

What is the String to Array Converter?
The String to Array Converter splits any delimited text — comma-separated values, lines, spaces, tabs, or a custom delimiter — into an array, output as JSON, a JavaScript array literal, one item per line, or quoted CSV.
How do I use the String to Array Converter?
Paste your text, choose the delimiter to split on and the output format, toggle trim/empty/duplicate options as needed, and click Convert. The item count and formatted array appear with a copy button.
Is my data private?
Yes. Splitting and formatting run entirely in your browser. Nothing is ever sent to a server.
What do the trim, empty, and duplicate options do?
"Trim items" strips whitespace around each item (so "a, b , c" gives clean values). "Remove empty" drops zero-length items caused by double delimiters or trailing separators. "Remove duplicates" keeps only the first occurrence of each value — handy for building unique lists.
Which output format should I pick?
JSON array for API payloads and config files; JS array (single quotes) for pasting into JavaScript/TypeScript source; one-per-line for spreadsheets and further text processing; quoted CSV for SQL IN (...) clauses and CSV imports where values may contain commas.

Related Workflows

Related Tools

Compare

Tool Trust & Transparency

Ecosystem Trust Center

Processed in

Your browser

Input never sent to any server

Input stored

No

No logs, no accounts required

Common use cases

  • Format, validate, or transform code and data without leaving your browser
  • Debug encoding, decoding, or conversion issues quickly
  • Generate test data or convert between formats in development workflows

Limitations

  • Operates entirely in your browser — large inputs may slow older devices
  • Output is a best-effort conversion; always validate critical results independently

Last verified: 2026 · Free, no account required · Validate critical output independently

Report an issue →