Commas to Spaces Converter
Convert commas to spaces instantly. Replace comma-separated values with space-delimited text. Supports bulk text, trim options, and custom delimiters.
About
Delimiter mismatches cause silent data corruption. A CSV field pasted into a space-delimited configuration file will break parsing without warning. This tool performs precise replacement of comma characters (,) with space characters (U+0020), handling edge cases that naive find-and-replace misses: consecutive commas, leading/trailing commas, and comma-space (, ) sequences that would otherwise produce double spaces. It operates entirely in-browser with zero server round-trips.
The converter processes arbitrary-length text in real time. It accounts for whitespace normalization - collapsing runs of multiple spaces into a single separator when enabled. This matters when transforming tag lists, log entries, or command-line arguments where extraneous whitespace causes failures. Note: this tool treats all comma codepoints equally and does not distinguish commas inside quoted strings. For RFC 4180-compliant CSV parsing, a dedicated CSV parser is required.
Formulas
The conversion applies a regular expression substitution over the input string S. The core operation is a pattern match and replace:
Where pattern is the RegExp that matches commas and optional surrounding whitespace, and delimiter is the replacement character (default: single space U+0020).
When whitespace normalization is enabled, the pattern expands to:
This captures zero or more whitespace characters (\s*) on both sides of one or more consecutive commas (,+), replacing the entire match with a single delimiter. The g flag ensures global replacement across all occurrences. When collapse mode is disabled, the simpler pattern /,/g performs a 1:1 character substitution.
Where S = input string, Sβ² = output string, pattern = compiled RegExp, delimiter = replacement string (space, tab, pipe, or custom).
Reference Data
| Scenario | Input Example | Output (Default) | Notes |
|---|---|---|---|
| Simple CSV list | apple,banana,cherry | apple banana cherry | Direct replacement |
| Comma-space sequence | apple, banana, cherry | apple banana cherry | Trims surrounding spaces when enabled |
| Multiple consecutive commas | a,,b,,,c | a b c | Collapsed to single space when enabled |
| Leading comma | ,hello,world | hello world | Leading delimiter trimmed |
| Trailing comma | hello,world, | hello world | Trailing delimiter trimmed |
| Mixed whitespace | a ,b , c | a b c | Normalized with trim option |
| Tab-mixed input | a,\tb,\tc | a \tb \tc | Only commas replaced; tabs preserved |
| Newline-separated rows | a,b\nc,d | a b\nc d | Newlines preserved; per-line processing |
| Single value | hello | hello | No commas; output unchanged |
| Empty input | (empty) | (empty) | Returns empty string |
| Numbers | 1,2,3,4,5 | 1 2 3 4 5 | Numeric data preserved exactly |
| Decimal numbers | 3.14,2.71,1.41 | 3.14 2.71 1.41 | Decimal points untouched |
| IP addresses | 192.168.1.1,10.0.0.1 | 192.168.1.1 10.0.0.1 | Dots preserved |
| Email list | [email protected],[email protected] | [email protected] [email protected] | Special characters preserved |
| Quoted strings | "a,b","c,d" | "a b" "c d" | No CSV quote awareness |
| Unicode text | ζ₯ζ¬,δΈε½,νκ΅ | ζ₯ζ¬ δΈε½ νκ΅ | Full Unicode support |
| URL parameters | key1=val1,key2=val2 | key1=val1 key2=val2 | Equals signs preserved |
| JSON-like array | [1,2,3] | [1 2 3] | Brackets preserved |
| Custom delimiter output | a,b,c β tab | a\tb\tc | When output set to tab character |
| Pipe delimiter output | a,b,c β pipe | a|b|c | When output set to pipe character |