Spaces to Commas

Paste a space-separated list. The tool replaces every space with a comma. Toggle "Trim entries" to strip whitespace around each value, and "Dedupe" to remove repeats. Useful for prepping data for spreadsheets and APIs.

Conversion rules

Trim each entry
Add space after comma
Dedupe entries
Quote each entry

What this converter does

You paste a space-separated list, the tool replaces every space with a comma. The most common end goal is to turn a one-per-word list into a CSV string you can paste into a spreadsheet cell, a SQL IN clause, an API filter parameter, or an autocomplete seed.

Four toggles control the output:

  • Trim each entry. Strip whitespace around each value before joining. Catches the ragged-spacing case from copy-paste.
  • Add space after comma. ON by default - "apple, banana, cherry". OFF produces compact CSV "apple,banana,cherry".
  • Dedupe entries. Remove repeat entries (case-sensitive). Order preserved.
  • Quote each entry. Wrap each entry in double quotes - "apple", "banana", "cherry". Useful for SQL or JSON-like output.

Common use cases

The conversion comes up constantly in data work: See also: Remove Whitespace.

  • SQL IN clauses. Paste a list of IDs, switch on Quote each entry, copy the output. WHERE id IN (123, 456, 789) ships in seconds.
  • Spreadsheet seeding. Excel and Google Sheets accept comma-separated input in a single cell with Data > Text to Columns. Convert your space-separated list first.
  • API filter parameters. Most REST endpoints accept comma-separated filter values: ?ids=123,456,789. Convert and paste.
  • Autocomplete seed lists. Many form-builders accept comma-separated initial options.
  • JSON array input. Combine with Quote each entry and surround with brackets for a valid JSON string array.

Edge cases the tool handles

Multiple spaces. Treated as a single separator. "apple banana" produces "apple, banana", not "apple, , banana". This works because the split regex is \s+ (one or more whitespace characters).

Newlines. Also treated as whitespace. Paste a column from a spreadsheet and the tool flattens it to a CSV row.

Tabs. Same as newlines and spaces - collapsed into the comma boundary.

Entries containing quotes. With Quote each entry ON, internal quotes get escaped (\") to keep the CSV valid.

Empty input. Produces empty output, not an error.

Reverse direction (commas to spaces)

Going the other way - turning a CSV back into a space-separated or newline-separated list - is just as common. For comma-to-newline, use the column-to-comma-separated tool which works in both directions. For removing commas without replacement, use remove commas. For more complex replace patterns (any character to any other character), use the word replacer with regex mode.

Frequently asked questions

What does the spaces-to-commas converter do?

It replaces every space (or run of whitespace) in your input with a comma, turning a space-separated list into a CSV string. Four toggles control trimming, comma spacing, deduplication, and quoting.

Does it handle multiple spaces?

Yes. Runs of whitespace (multiple spaces, tabs, newlines) collapse into a single comma boundary. "apple banana" produces "apple, banana", not "apple, , banana".

Can I dedupe entries?

Yes. Toggle Dedupe ON to remove repeat entries, preserving order. Case-sensitive - "Apple" and "apple" are treated as different unless you lowercase your input first.

Does it quote each entry?

Optional via the Quote each entry toggle. When ON, each entry is wrapped in double quotes ("apple", "banana"), and internal quotes are escaped (\"). Useful for SQL IN clauses, JSON array preparation, or CSV with quoted strings.

Why is "spaces to commas" useful?

Common use cases: building SQL IN clauses, seeding spreadsheet columns, preparing API filter parameters, converting one-per-line lists to comma-separated for autocomplete.

Can I go the other direction (commas to spaces)?

Not on this page. For comma-to-newline conversion, use column-to-comma-separated which works both directions. For commas-to-anything-else, use the word replacer.

What's the line limit?

No hard limit. The conversion is a single regex split + join and runs instantly on inputs up to several million characters.

Is the text uploaded?

No. Every operation runs in JavaScript in your browser. The input never leaves the page.

Related tools

More wordcounter.ai tools

Other tools you might find useful.

Browse the full catalog →