Skip to content

Find and Replace

Mode

One word or phrase per line; every line gets the same replacement.

More options
Text after replacing
—
Replacements
—
Lines changed
—

Paste your text, type what to find and what to put in its place, and every match changes at once. For example, finding cat and replacing it with dog in "The cat sat on the cat mat." makes 2 replacements. Switch to Regex for patterns with capture groups, or Pair list to apply dozens of old => new edits in one pass.

About this tool

Editors cleaning a CSV export, translators swapping British for American spelling, and developers testing a pattern before they put it in code all need the same thing: change many matches without missing one. This page has three modes. Find text replaces an exact word or phrase; put several on separate lines to send them all to one replacement, which is handy for masking names. Match case and Whole words only sit under More options. Regex takes a JavaScript regular expression and lets the replacement reuse captured groups as $1 and $2. Pair list applies one old => new line after another, so a whole style sheet of spelling fixes runs in one go. The result box shows the new text, the number of replacements and the lines changed, and with two or more search lines a table counts matches per term. Everything runs in your browser. One limit: regex syntax follows JavaScript, so Python-only features such as possessive quantifiers will not work.

How to use it

  1. Paste or open your text

    Type into Your text, or use Open a text file to load a .txt, .csv or .md file from your device.

  2. Pick a mode

    Find text for one or several words, Regex for a pattern, Pair list for many old => new lines.

  3. Set the options

    Open More options and tick Match case to keep Cat and cat apart, or Whole words only so cat does not hit category.

  4. Copy the result

    The new text appears as you type with the replacement count; with several search lines a table splits the count per term.

Examples

Swap one word everywhere

Mode
Find text
Your text
The cat sat on the cat mat.
Find
cat
Replace with
dog

Result Text after replacing: The dog sat on the dog mat.
Replacements: 2
Lines changed: 1

  1. Searched for the exact text "cat", ignoring case.
  2. 2 replacements made; 1 of 1 lines changed.

Both copies of cat change in one pass, and the count confirms two replacements.

Flip first and last names with groups

Mode
Regex
Your text
John Smith
Pattern
(\w+)\s(\w+)
Replace with
$2, $1
Match case
Yes

Result Text after replacing: Smith, John
Replacements: 1
Lines changed: 1

  1. Pattern /(\w+)\s(\w+)/ with flags gu; $1, $2 … in the replacement insert the captured groups, $& the whole match.
  2. 1 replacement made; 1 of 1 lines changed.

The two brackets capture each name; $2, $1 writes them back in reverse order with a comma.

British to American spelling in one go

Mode
Pair list
Your text
The colour and flavour of the centre.
Find => replace, one per line
colour => color flavour => flavor centre => center

Result Text after replacing: The color and flavor of the center.
Replacements: 3
Lines changed: 1

  1. 3 pairs applied top to bottom; each later pair sees the text after the earlier ones.
  2. 3 replacements made; 1 of 1 lines changed.

Three pairs run top to bottom, and the table shows that each matched once.

How it is calculated

result = text with every non-overlapping match of the search replaced, scanning left to right (ECMA-262 String.prototype.replace with the global flag)

Plain searches are escaped, so a dot or bracket you type is matched literally and a $ in the replacement stays a $. Regex mode builds a RegExp with the g and u flags, adds i unless Match case is on, and m when ^ and $ should match each line. In the replacement, $1 to $99 insert captured groups, $& inserts the whole match and $$ writes a dollar sign. Whole words only wraps the search in lookarounds that refuse a letter, digit or underscore on either side, in any script. Pair list runs its lines in order, so a later pair sees text already changed by earlier ones. Several lines in Find text are sorted longest first, so New York is replaced before York.

Sources

Use from code or an AI agent Free API · MCP

The same calculation is a free JSON API. No key needed. The answer is in result.stats.primary.

curl -X POST https://api.tools-directory.workers.dev/v1/tools/find-and-replace \
  -H 'Content-Type: application/json' \
  -d '{"inputs":{"mode":"plain","text":"The cat sat on the cat mat.","find":"cat","replace":"dog"}}'

When not to use it

  • Do not use it to edit a .docx or .xlsx file directly; paste the text out, or use the program's own replace dialog.
  • Renaming a variable across a code base needs your editor's refactor command, which understands scope.
  • Very large logs of many megabytes are better handled with sed or grep on the command line.

Common mistakes

  • Leaving Whole words only off, so replacing he also changes the and when.
  • Typing a regex special character such as . or ( in Find text and expecting it to act as a pattern.
  • Ordering pairs so an early pair creates text that a later pair then changes again.
  • Writing \1 for a group in the replacement; JavaScript uses $1.

Frequently asked questions

How do I find and replace in Word?

In Microsoft Word open Replace with Ctrl+H on Windows or Cmd+Shift+H on a Mac, type the text in Find what and Replace with, then press Replace All. Word's More button adds Match case and Find whole words only, the same two switches this page offers. Wildcards in Word use their own syntax, not regex.

How do I find and replace in Excel?

Press Ctrl+H in Excel, enter Find what and Replace with, and choose Replace All. Options lets you limit the search to the sheet or workbook and match the entire cell contents. Excel's find accepts * and ? as wildcards; put a tilde before them, as in ~*, to find a literal asterisk.

What is the find and replace shortcut?

Ctrl+H opens find and replace in Word, Excel, Google Docs, Google Sheets, Notepad and most Windows editors. On a Mac, Word uses Cmd+Shift+H, Google Docs uses Cmd+Shift+H, and VS Code uses Option+Cmd+F. Ctrl+F alone usually opens find without the replace box.

How do I find and replace in Google Docs?

In Google Docs choose Edit, then Find and replace, or press Ctrl+H (Cmd+Shift+H on a Mac). Tick Match case if needed, and tick Use regular expressions to search with patterns. Docs uses RE2 syntax, and its replace box accepts $1 for a captured group.

How do I find and replace in VS Code?

Press Ctrl+H (Option+Cmd+F on a Mac) for the current file, or Ctrl+Shift+H to replace across every file in the workspace. The .* button turns on regular expressions, and the replacement can use $1 for groups. VS Code uses JavaScript regex, so a pattern you test in Regex mode here behaves the same.

How do I use a regex replace with a capture group?

Wrap the part you want to keep in brackets and refer to it as $1, $2 and so on in the replacement. The pattern (\w+)\s(\w+) with $2, $1 turns John Smith into Smith, John. A group can also be skipped with (?:…) when you only need it for alternatives, and $& inserts the whole match.

How do I do a regex replace in Python?

Use re.sub(pattern, replacement, text). Python writes groups as \1 or \g<1> in the replacement instead of $1, so r'(\w+)\s(\w+)' with r'\2, \1' gives the same flip as our example. Most simple patterns are shared between Python and JavaScript, so you can draft one here and change the group syntax.

How can I do a bulk find and replace of many words at once?

Choose Pair list and write one old => new pair per line, such as colour => color. Every pair runs in order on the same text, and the table counts how many times each matched. When all the words should become the same thing, such as a mask, list them one per line in Find text instead.

Cite this tool

Using this tool in an assignment, article or report? Copy a citation, or a link for your website.

APA

Tools Directory Editorial Team. (2026, November 30). Find and Replace. Tools Directory. Retrieved December 1, 2026, from https://directory.milunir.com/text-tools/text-formatting/find-and-replace/

MLA

Tools Directory Editorial Team. “Find and Replace.” Tools Directory, 30 Nov. 2026, https://directory.milunir.com/text-tools/text-formatting/find-and-replace/. Accessed 1 Dec. 2026.

Chicago

Tools Directory Editorial Team. “Find and Replace.” Tools Directory. Last modified November 30, 2026. Accessed December 1, 2026. https://directory.milunir.com/text-tools/text-formatting/find-and-replace/.

Link<a href="https://directory.milunir.com/text-tools/text-formatting/find-and-replace/">Find and Replace – Tools Directory</a>