Skip to content

Find and Replace Text Online

Replace every occurrence of a word, phrase or pattern in pasted text in one pass, with a match count, optional case matching and regular expressions.

Runs in your browserFree, no sign-upLast reviewed

Settings

Results update automatically as you type.

Replacements

Matches found
2
Mode
Plain text

Result

The dog sat on the mat. The dog was happy.

Quick answers

How do I find and replace all occurrences of a word in text?
Paste the text, type the word in Find and the new word in Replace with. Every occurrence is replaced at once, not just the first, and Matches found shows how many were changed. There is no separate Replace all button to press.
How do I replace whole words only?
Tick the regular expression box and wrap the word in \b markers. Finding \bcat\b in category cat concat Cat replaces 2 matches and gives category dog concat dog. Without the markers, plain cat matches 4 times and turns category into dogegory.
Is find and replace case sensitive?
Not by default. Finding the in the sample text matches The and the, 3 matches in all. Tick Match letter case to match only the exact capitalization, which drops that to 1. The replacement is always inserted exactly as you typed it.
How do I delete a word from text everywhere it appears?
Type the word in Find and leave Replace with empty. Every match is removed. The spaces around the word stay, so removing cat from The cat sat leaves two spaces; include one space in the Find box to avoid that.
How do I replace line breaks with commas?
Tick the regular expression box, type \n in Find and a comma and space in Replace with. Three lines reading line one, line two and line three become line one, line two, line three on a single line. In plain-text mode \n is searched for literally and matches nothing.
Can I find and replace several different words at once?
Yes when they all change to the same thing: tick the regular expression box and separate the words with a vertical bar, such as cat|dog|hamster. Different replacements for different words need one pass each; copy the Result back into the text box between passes.

Why use Find and Replace Text

Paste your text, type the word or phrase to look for in Find and its substitute in Replace with, and the Result panel shows the text with every occurrence swapped. A Matches found figure tells you how many replacements were made. With the sample text, finding cat and replacing with dog changes 2 matches and returns "The dog sat on the mat. The dog was happy." Matching ignores capital letters unless you tick Match letter case, and it matches inside longer words. Ticking the regular expression box lets you use patterns, capture groups and whole-word anchors. Leaving Replace with empty deletes every match.

Plain-text find and replace examples

These use the default settings: regular expression off, Match letter case off.

Rename a company in every spelling

Text: Acme Ltd signed. ACME LTD paid. acme ltd left. Find: Acme Ltd. Replace with: Acme Inc

Acme Inc signed. Acme Inc paid. Acme Inc left. (3 matches)

With Match letter case ticked, only the first is replaced and the count is 1.

Fix a repeated typo

Text: recieve, Recieve, recieved. Find: recieve. Replace with: receive

receive, receive, received (3 matches)

The capital R is lost because the replacement is inserted as typed. Run a second, case-matched pass for capitalized forms if that matters.

Change a list separator

Text: apple;banana;cherry. Find: ; Replace with: ,

apple,banana,cherry (2 matches)

Search for punctuation literally

Text: a.b.c. Find: . Replace with: -

a-b-c (2 matches)

In plain-text mode a period is just a period. Brackets work the same way: finding (1) in Total (1) and (2) replaces only the bracketed 1.

Wrap each match instead of replacing it

Text: The cat sat. The cat ran. Find: cat. Replace with: [$&]

The [cat] sat. The [cat] ran. (2 matches)

$& in the Replace with box stands for whatever was matched.

Regex find and replace patterns you can copy

Tick Treat 'Find' as a regular expression first. Every result below was produced by this tool.

TaskFindReplace withBeforeAfter
Whole word only\bcat\bdogcategory cat concat Catcategory dog concat dog
Several words to onecat|dog|hamsterpetI have a cat, a dog and a hamster.I have a pet, a pet and a pet.
Either spellingcolou?rhuecolour color Colourhue hue hue
Collapse repeated spaces\s+one spacetoo many spaces heretoo many spaces here
Line breaks to commas\n, line one / line two / line three on separate linesline one, line two, line three
Tabs to commas\t,one / two / three separated by tabsone,two,three
Strip HTML tags<[^>]+>(empty)<b>bold</b> and <i>italic</i>bold and italic
Mask digits\d#call 555-1234 or 555-9876call ###-#### or ###-####
Hide email addresses[\w.]+@[\w.]+[email]jane@example.com, bob@test.org[email], [email]
Swap last and first name(\w+), (\w+)$2 $1Smith, JohnJohn Smith
Reorder a date(\d{4})-(\d{2})-(\d{2})$3/$2/$12026-10-0808/10/2026
Change a title, keep the nameMr (\w+)Dr $1Mr Smith met Mr JonesDr Smith met Dr Jones
Remove a tracking parameterutm_[a-z]+=[^&]+&?(empty)https://example.com/page?utm_source=news&id=4https://example.com/page?id=4

Patterns use JavaScript regular expression syntax. Remember that matching is case-insensitive unless Match letter case is ticked, so \bcat\b also matches Cat.

Special codes in the Replace with box

The replacement is not always inserted literally. A dollar sign followed by certain characters has a meaning, in plain-text mode as well as regex mode.

You typeWhat is insertedExample
$&The whole matched textFind cat, replace with [$&]: [cat]
$1, $2 ...The first, second ... capture group (regex mode)Find (\w+), (\w+), replace with $2 $1: John Smith
$<name>A named capture group (regex mode)Find (?<y>\d{4})-(?<m>\d{2})-(?<d>\d{2}), replace with $<m>/$<d>/$<y>: 10/08/2026
$$One literal dollar signFind (\d+) USD, replace with $$$1: $5
$` or $'The text before the match, or the text after itRarely wanted; write $$ when a dollar sign must be followed by a backtick or apostrophe
$5.00$5.00, unchanged when no fifth group existsFind 5.00, replace with $5.00: It costs $5.00
\n or \tThe two characters as typed, not a line break or tabFind a comma and space, replace with \n: a\nb\nc

Because \n is not converted in the replacement, this tool cannot insert line breaks. It can remove them or swap them for other characters.

How matching behaves, and what is not supported

  • All matches are replaced. There is no replace-first-only or step-through mode.
  • Plain-text mode matches inside longer words. There is no whole-word checkbox; use \b in regex mode.
  • One Find and one Replace with value per run. A list of different find-and-replace pairs has to be applied one after another.
  • In regex mode, ^ and $ match only the very start and very end of the whole text, not each line. Finding ^line in three lines that each start with line changes only the first.
  • A period in regex mode does not match a line break. Use [\s\S] to match across lines.
  • An invalid pattern, such as a lone opening bracket, shows the message "That regular expression is not valid." and nothing is changed.
  • If nothing matches, Matches found shows 0 and the Result is the original text.

Plain text or regular expression: which mode to use

Use plain-text mode whenever you are looking for an exact word, phrase or symbol. Everything you type in Find is treated literally, so a period, question mark, bracket or asterisk matches only itself. Searching for e.g. in the text e.g. eggs e.g. finds 2 matches in plain-text mode.

Switch to regex mode when you need a rule rather than a fixed string: whole words only, any digit, runs of spaces, line breaks, or rearranging parts of each match. In this mode punctuation has special meanings, and the same search for e.g. finds 3 matches, because each period now means any character and so eggs matches too. To search for a literal period, bracket or other special character in regex mode, put a backslash before it, as in e\.g\.

A quick safety check in either mode is the Matches found figure. If it is much higher than you expected, the search is probably matching inside longer words; if it is 0, check the capitalization setting and look for a stray space at the end of the Find box.

How to get your result

  1. 1

    Paste the text you want to edit into the Your text box.

  2. 2

    Type the word, phrase or pattern in Find, and what should take its place in Replace with. Leave Replace with empty to delete the matches.

  3. 3

    Tick Match letter case if cat and Cat should be treated as different.

  4. 4

    Tick Treat 'Find' as a regular expression to use patterns such as \bcat\b or \s+.

  5. 5

    Check Matches found, then copy the Result or download it as replaced.txt.

Questions people ask

Can I find and replace in a Word document, PDF or spreadsheet file?
Not as a file. The tool works on text pasted into the box and returns plain text, so formatting such as bold, tables and fonts is not preserved. For a formatted document, use the editor's own Find and Replace, usually Ctrl+H on Windows.
Why is the match count higher than I expected?
Plain-text matching is case-insensitive and matches inside other words, so cat also counts Cat, category and concat. Tick Match letter case, or switch to regex mode and search for \bcat\b, to narrow it to the standalone word.
How do I put a dollar sign in the replacement?
A single $ followed by a space or a digit with no matching group is inserted as typed, so $5.00 works. To be safe, and always directly before a capture group reference, write $$ for one dollar sign: replacing (\d+) USD with $$$1 turns 5 USD into $5.
Can it replace text with a line break?
No. The Replace with field is a single line and escape codes such as \n are inserted as the literal characters backslash and n. You can replace line breaks with something else, but not add new ones. A text editor's regex replace handles that case.
Does the tool keep the capitalization of the word it replaces?
No. The replacement is inserted exactly as typed for every match. Replacing recieve with receive also turns Recieve into lowercase receive. To preserve capitals, tick Match letter case and run one pass for each capitalization.
How do I remove extra spaces or blank lines?
In regex mode, find \s+ and replace with a single space to collapse every run of spaces, tabs and line breaks into one space. To keep the line breaks, find a space followed by + instead. To delete blank lines, find \n(?=\n) and leave Replace with empty. To trim spaces at the ends of lines, find [ \t]+(?=\n|$) with an empty replacement.
Is my text sent anywhere?
No. The search and replacement run in your browser with JavaScript, and the text is not uploaded, so it is suitable for logs, drafts and other material you would not paste into a server-side tool.
What regex flavor does it use?
JavaScript regular expressions, with the global flag always on and the ignore-case flag on unless Match letter case is ticked. Lookaheads, named groups, \d, \w, \s and \b all work. There are no switches for the multiline, dot-matches-newline or Unicode flags, so ^ and $ anchor to the whole text and \p{L} classes do not work.

Looking for something else? Browse all text tools or see every tool.