Find and Replace Text

Replace every occurrence of a word, phrase or pattern in your text and see how many changes were made. This free tool offers case, whole-word and regular expression options, updates as you type, and runs in your browser, so your text is never uploaded.

Find and Replace TextPrivate · runs on your device
Input
Words 0Characters 0Lines 0
Modified text

Example: cat and cat → dog and dog

How to use the find and replace tool

It works like the find and replace box of a word processor, without opening a document. There is no Replace button: the result refreshes whenever you change any box.

  1. Paste your text into the Input box. It can be a sentence, a list, a data export or a block of code.
  2. Type what you are looking for in the Find field.
  3. Type the new text in Replace with. Leave it empty to delete every match.
  4. Tick Case sensitive, Whole words only or Regular expression if you need them.
  5. Read the result in the Modified text box. A note under it says how many replacements were made. Press Copy or Download .txt, or press Use as input to chain another replacement.

Your original stays in the Input box, so nothing is overwritten. With the text cat and cat, finding cat and replacing it with dog gives dog and dog and reports 2 replacements.

What the three options do

The match is global, so every occurrence changes, not just the first.

  • Case sensitive is off by default, so Cat, cat and CAT all match. The replacement is inserted exactly as typed, so Cat becomes dog, not Dog.
  • Whole words only adds word boundaries around the search. With cat replaced by dog, the text Cat category concatenate bobcat cat. becomes dog category concatenate bobcat dog. The boundary recognises only plain letters, digits and the underscore, so accented letters count as breaks and caf still matches inside café. A term that starts or ends with a symbol, such as C++, never matches as a whole word.
  • Regular expression treats Find as a JavaScript pattern. Brackets, dots and dollar signs are literal when this box is off, so finding $5 and replacing it with $10 works as typed.

In regular expression mode, only the global and case-insensitive flags are used. That has three consequences: ^ and $ match the start and end of the whole text and not of each line, a dot does not match a line break, and you write \n for a line break. An invalid pattern shows Invalid regular expression and leaves the text unchanged. To build and test a pattern first, use the regex tester.

Patterns, groups and everyday jobs

In regular expression mode the replacement can refer to what was matched: $& is the whole match, and $1, $2 are the bracketed groups.

FindReplace withEffect
(\w+) (\w+)$2, $1John Smith becomes Smith, John
\d+#a1b22c333 becomes a#b#c#, 3 replacements
\na single spacejoins lines into one
(cat|dog)petreplaces either word in one pass

With Whole words only on, wrap alternatives in brackets as in the last row. Without them the boundaries attach only to the first and last alternative.

  • Data clean-up. Swap a delimiter, change a placeholder date or rename a product code across many rows.
  • Drafts. Correct a misspelled name everywhere, or switch between spelling conventions.
  • Templates. Fill in placeholders such as [DATE] one pair at a time.

If the note says 0 replacements, the pattern found nothing. Check the spelling, the case setting and whether Whole words only is blocking a match, and in regular expression mode check for special characters such as a bracket or a plus sign that need a backslash to be literal. You can always undo a change by clearing the Find field, which shows your text untouched, because the output is a separate copy and the Input box is never altered. Everything runs in your browser, so even long texts of thousands of lines are replaced without being uploaded.

The tool handles one find and replace pair per pass. For tidying whitespace, the whitespace remover and the line break remover are quicker, and the diff checker shows exactly what changed.

Quick answers

Frequently asked questions

The questions people ask most, answered in plain words.

How do I replace a word everywhere in a text?

Paste the text, type the word into Find and its replacement into Replace with. The result appears at once with a count of replacements. Tick Whole words only if you want to avoid changing longer words that contain the same letters.

Can I replace several different words at the same time?

Not with separate pairs, because the tool handles one pair per pass. Either press Use as input after each pass to chain them, or tick Regular expression and find (cat|dog) to replace both words with one value in a single pass.

What does Whole words only do?

It limits matches to complete words by adding word boundaries around the search. With it on, searching for cat changes cat but leaves category and bobcat alone. It treats accented letters as breaks and will not match terms that begin or end with symbols, such as C++.

How can I replace line breaks or tabs?

Tick Regular expression, then type \n in Find for a line break, \t for a tab, or \s+ for any run of white space. Put the replacement in Replace with, for example a single space, and every match is swapped across the whole text.

Does the tool support regex capture groups?

Yes. Wrap part of the pattern in brackets and refer to it in the replacement as $1, $2 and so on. Finding (\w+) (\w+) and replacing with $2, $1 turns John Smith into Smith, John. Without Regular expression ticked, a dollar sign is treated literally.