Overview
Introduction
Turning space-separated text into a one-item-per-line list makes it easy to sort, filter, or paste into a spreadsheet column.
This tool does that conversion in one step.
What Is Spaces to Newlines?
A converter that replaces every run of one or more spaces with a single newline character.
It runs entirely client-side as part of this site's String Tools collection, so nothing you paste is ever uploaded to a server.
How Spaces to Newlines Works
A regex matching one or more consecutive spaces is replaced globally with a newline.
The transformation happens synchronously in JavaScript the moment you type, with no network round trip involved.
When To Use Spaces to Newlines
Use it to turn a space-separated list of words or tags into a line-per-item list for further processing, sorting, or pasting into a spreadsheet.
It's a fast way to get the answer without opening a code editor, a REPL, or writing a one-off script just to check.
Often used alongside Newlines to Spaces and Text Splitter.
Features
Advantages
- Collapses multiple consecutive spaces into a single newline rather than producing blank lines.
- Matches whole runs rather than single spaces, so irregular spacing still produces exactly one line per value instead of blank lines between them.
- Leaves existing newlines untouched, so text that is already partly line-separated can be normalized without doubling up its breaks.
Limitations
- Only matches literal space characters, not tabs or other whitespace.
- Splits at every space, so a value containing an internal space is broken across two lines with no way to tell where it happened.
Examples
Best Practices & Notes
Best Practices
- Pair with Sort Strings or Remove All Empty Lines afterward for further list cleanup.
- Trim the input first, otherwise leading or trailing spaces leave empty lines at the ends of the list.
- Confirm no value contains a space of its own before converting, since those values split apart irrecoverably.
Developer Notes
The regex `/ +/g` collapses runs of spaces (not single spaces individually) into one newline each, avoiding blank lines from consecutive spaces.
Spaces to Newlines Use Cases
- Converting a space-separated tag list into one tag per line
- Preparing space-separated values for a spreadsheet paste
- Turning a sentence into one word per line for processing
Common Mistakes
- Expecting tabs to also convert; only literal spaces are matched.
- Converting a sentence rather than a list of values, which puts every single word on its own line.
Tips
- Use Newlines to Spaces to reverse this operation.
- Follow with the Empty Line Remover when the source mixed spaces and tabs, since tabs are left in place and can produce odd-looking lines.