Find and replace text online
Replace every occurrence of a word or phrase at once, with match-case, whole-word and regular expression options.
How to find and replace text
- 1Paste your text into the left box.
- 2Type what to find and what to replace it with.
- 3Tick Match case, Whole words or Regex as needed.
- 4Check the match count, then press Copy result.
Useful find and replace patterns
Tick Regex to use these:
- \s{2,} → one space: collapse repeated spaces.
- ^\s+|\s+$ → nothing: trim the start and end of every line.
- \n → , : turn lines into a comma-separated list.
- (\w+), (\w+) → $2 $1: swap "Smith, Jo" to "Jo Smith".
- \d{4}-\d{2}-\d{2}: find every ISO date such as 2026-10-07.
- [“”] → ": replace curly quotes with straight ones.
Several clean-ups have their own tools: remove extra spaces, remove line breaks and change case.
Frequently asked questions
How do I replace a word in a block of text? +
Paste the text, type the word in "Find" and its replacement in "Replace with". Every occurrence is replaced at once and the number of replacements is shown under the boxes. Leave "Replace with" empty to delete the word.
What does "Whole words" do? +
It only matches the word on its own, so replacing "cat" will not change "concatenate" or "category". Without it, every occurrence of the letters is replaced, including inside longer words.
How do I use regular expressions? +
Tick "Regex" and write a JavaScript regular expression in Find. For example, \d+ matches any number, \s+ any run of whitespace, and ^ the start of a line (the m flag is on, so ^ and $ work per line). In Replace with, $1 inserts the first capture group and $& the whole match: finding (\w+)@(\w+) and replacing with $2 at $1 swaps the parts of an email address.
Can I replace line breaks or tabs? +
With Regex on, use \n for a line break and \t for a tab in Find, for example \n to replace every line break with a comma. Without Regex, you can paste a tab character directly into Find.
Why did my regex stop with an error? +
Either the pattern is not valid JavaScript regex syntax, in which case the error is shown, or it took more than two seconds on your text. Some patterns, such as nested repeats like (a+)+, can take an extremely long time on certain inputs; the tool stops them instead of freezing your browser.
How do I find and replace in Word or Google Docs? +
In Word, press Ctrl+H on Windows or Mac to open Replace. In Google Docs, press Ctrl+H (Cmd+Shift+H on Mac) or choose Edit > Find and replace; tick "Use regular expressions" for patterns.