Replace Spaces changes every space in your text to an underscore, dash, comma or any text you choose. Paste your text, click the button and copy the result. It is free and runs in your browser.
He decided to move to a smaller house
He_decided_to_move_to_a_smaller_house
Bookmark: press Ctrl+D (Windows) or Cmd+D (Mac) to save this tool.
This tool replaces the spaces in your text with anything you type. Enter an underscore, a dash, a comma, a period or a whole word in the box, click the button, and every space is swapped for it.
Tabs and non-breaking spaces are replaced too, because they look like spaces. If your text has runs of several spaces, you can tick an option to treat each run as one, so you get one underscore instead of three. You can also keep the spaces at the start and end of each line.
Use it to make file names, URL slugs and variable names, to join words for hashtags, or to prepare text for a program that does not accept spaces.
Each example shows what the Replace spaces with box held. Unless an option is named, every space is replaced, tabs count as spaces and spaces at the edges are replaced too.
| Setting | Before | After |
|---|---|---|
| Underscore (_) | He decided to move to a smaller house | He_decided_to_move_to_a_smaller_house |
| Dash (-) | red green blue | red-green-blue |
| Comma and space (, ) | one two three | one, two, three |
| Word (and) | salt pepper | saltandpepper |
| Several spaces, each replaced | a b | a__b |
| Several spaces as one | a b c | a_b_c |
| Tabs replaced | a b c | a_b_c |
| Tabs not replaced | a b c | a b_c |
| Spaces at the edges, replaced | a b | __a_b__ |
| Spaces at the edges, kept | a b | a_b |
| Line breaks stay | a b c d | a_b c_d |
| Empty box, spaces removed | a b c | abc |
Making file names, URL slugs, hashtags and variable names, and preparing text for programs, forms or systems that do not accept spaces.
The text you type is used exactly as written, so to get a space after a comma, type a comma and a space. Spaces at the start and end of the text are replaced too, unless you keep them. The result replaces your text, so use Undo if you need the original.
To delete spaces completely, try Remove Spaces. To turn spaces into new lines, try Convert Spaces to New Lines. To make double spaces single, try Convert Double Space to Single Space.
It replaces every space in your text with the text you enter, such as an underscore, a dash, a comma, a period or a word.
Paste your text, type an underscore in the Replace spaces with box, then click Replace Spaces.
Anything you can type: one character like - or _, several characters like ', ', or a whole word.
Yes. Leave the Replace spaces with box empty and click the button, and the spaces are deleted.
By default each space is replaced, so two spaces become two underscores. Tick Treat several spaces in a row as one to get a single replacement for the whole run.
Yes, by default, because they look like spaces. Untick that option to replace normal spaces only.
Yes. Tick Keep spaces at the start and end of each line, and only the spaces between words are replaced.
No. Line breaks, letters, numbers and punctuation stay as they are. If there are no spaces the tool shows a message and leaves your text as it is.
Yes. It is free, needs no account and runs in your browser, so your text is not uploaded to a server.
Last updated: 14 November 2026