Skip to content
Case Converter Online
en

Remove Underscores from Text

Turn user_first_name into user first name in one step. Replace underscores with spaces, hyphens or nothing, and keep email addresses and links working.

Replace underscores with
Options
Characters
0
Words
0
Lines
0

Runs in your browser. Your text is never uploaded.

Why remove underscores?

Underscores join words where spaces are not allowed. You see them in file names (my_file_name_final.docx), database columns (user_first_name), programming variables, exported spreadsheet headers, hashtags and old usernames. When that text needs to be read by people, the underscores get in the way. Replacing them by hand is slow and easy to get wrong in a long list.

This tool replaces every underscore in one pass. It can put a space, a hyphen or nothing in its place, it can merge runs of underscores, and it leaves email addresses and web links alone so they keep working.

How to use it

  1. Paste your text into Text with underscores.
  2. Under Replace underscores with, choose A space, Nothing or A hyphen.
  3. Leave Merge repeated underscores on to treat ___ as a single gap.
  4. Leave Skip email addresses and links on so addresses are not broken.
  5. With A space chosen, Remove extra spaces also cleans up double spaces and spaces at line ends.
  6. Press Copy or Download. The note under the tool says how many underscores were removed.

Examples

Every result below was produced by this tool. The default settings were used unless the second column says otherwise.

Text Setting Result
my_file_name_final.docx A space my file name final.docx
Q3_sales_report_v2.xlsx A space Q3 sales report v2.xlsx
user_first_name A space user first name
user_first_name Nothing userfirstname
user_first_name A hyphen user-first-name
the__draft A space the draft
SECTION___TWO A hyphen, merge off SECTION---TWO
Email [email protected] about the__draft A space Email [email protected] about the draft
see https://site.com/my_page A space, skip links off see https://site.com/my page

How it works

The tool first finds anything that looks like a web link (starting with http://, https:// or www.) or an email address. Those parts are set aside. In the rest of the text, each underscore, or each run of underscores when merging is on, is replaced with your chosen character. Then the protected parts are put back exactly as they were.

With A space chosen and Remove extra spaces on, double spaces created by the swap are reduced to one, and spaces at the start and end of each line are trimmed. That matters for text such as “draft”, which would otherwise start and end with a space.

Tips and limits

  • Capital letters are not changed. user_first_name becomes “user first name”, not “User First Name”. To change the capitals afterwards, use a case converter such as title case or sentence case.
  • Going the other way: to turn words into underscored names, use the snake case converter.
  • Markdown italics written with underscores, such as word, lose their underscores too. That is usually what you want when cleaning text.
  • Other separators such as dots or hyphens are not touched. For those, use find and replace, which can swap any character or word.
  • Other symbols: to strip underscores together with other punctuation and symbols, use the special character remover.

Other ways to do it

Word and Google Docs: open Find and replace (Ctrl+H), type _ in the find box and a space in the replace box, then choose Replace all. This changes email addresses too, so check them afterwards.

Excel and Google Sheets: =SUBSTITUTE(A1, "_", " ") replaces every underscore in cell A1 with a space. Fill the formula down to do a whole column. To clean up the double spaces it can leave behind, wrap it in TRIM: =TRIM(SUBSTITUTE(A1, "_", " ")).

File names: Windows PowerShell can rename files in bulk with Get-ChildItem | Rename-Item -NewName { $_.Name -replace '_', ' ' }. On a Mac, select the files in Finder, right-click and choose Rename, then use Replace Text.

Code: in JavaScript, text.replaceAll('_', ' ') does the basic job. In Python, use text.replace('_', ' '). To merge runs of underscores, use a regular expression such as /_+/g in JavaScript or re.sub(r'_+', ' ', text) in Python.

Underscore Remover: questions and answers

How do I replace underscores with spaces?

Paste your text into the Text with underscores box. With A space selected, every underscore becomes a space straight away. Press Copy to take the result.

Does it change email addresses and web links?

Not by default. Skip email addresses and links is on, so [email protected] and https://site.com/my_page keep their underscores and still work. Switch the option off if you want those changed too.

What happens to two or more underscores in a row?

With Merge repeated underscores on, a run such as the__draft or hello___world is treated as one gap and becomes a single space. Switch it off to replace every underscore on its own.

Can I turn underscores into hyphens instead?

Yes. Choose A hyphen under Replace underscores with. user_first_name becomes user-first-name, which is the usual style for web addresses.

More text tools

See all tools