Find and Replace
Replacing “cat” with “dog” in the example text finds 5 matches and changes them all: “The dog sat on the mat with another dog. ↵ dog food is not a dogalog item, and dogs purr.”. That default search ignores case and also matches inside longer words, which is how “catalog” became “dogalog”; turn on Whole word and it is 3 matches, and with Case sensitive as well 2. Add more pairs to run several replacements in order, switch on Regular expression to rearrange text with $1 and $2, or replace one match at a time. Your text never leaves the browser.
Updated Runs in your browser: nothing you enter is uploadedHow this tool works
Replace the example: paste or type up to 1,000,000 characters. The matches update as you type.
The text, the searches and the results are handled on this device and never uploaded or saved. Reload the page and they are gone.
What to find and replace
With several pairs, they run from the first to the last, each one on the result of the one before.
Matches in your text
5 matches
The cat sat on the mat with another cat. Cat food is not a catalog item, and cats purr.
Replace changes the text above and moves to the next match. Only the pair chosen in “Show pair” is used while stepping.
Result
5 matches, all replaced in the result.
Counts
- Matches
- 5
- Characters in
- 88
- Characters out
- 88
What each option changes
| Settings | Matches | Result | Why |
|---|---|---|---|
| Default: ignore case, match anywhere | 5 | The dog sat on the mat with another dog. ↵ dog food is not a dogalog item, and dogs purr. | Finds “cat” in “Cat”, “catalog” and “cats” as well as the plain word. |
| Case sensitive | 4 | The dog sat on the mat with another dog. ↵ Cat food is not a dogalog item, and dogs purr. | Skips the capital “Cat”. |
| Whole word | 3 | The dog sat on the mat with another dog. ↵ dog food is not a catalog item, and cats purr. | Skips “catalog” and “cats”: a match may not touch another letter, digit or underscore. |
| Case sensitive and whole word | 2 | The dog sat on the mat with another dog. ↵ Cat food is not a catalog item, and cats purr. | Only the two lowercase, stand-alone “cat”. |
Replacement codes in regular expression mode
| Code | What it inserts | Find | Replace with | Text → result |
|---|---|---|---|---|
| $1, $2, $3 | What group 1, 2 or 3 (a pair of parentheses, counted by its opening bracket) matched. | “(\d{4})-(\d{2})-(\d{2})” | “$3/$2/$1” | “2026-11-02” → “02/11/2026” |
| $<name> | What the named group (?<name>…) matched. | “(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})” | “$<month>/$<day>/$<year>” | “2026-11-02” → “11/02/2026” |
| $& | The whole match. | “\d+” | “[$&]” | “Room 42” → “Room [42]” |
| $$ | A literal dollar sign. | “\d+” | “$$$&” | “Room 42” → “Room $42” |
| $` | The text before the match. | “-” | “[$`]” | “a-b” → “a[a]b” |
| $' | The text after the match. | “-” | “[$']” | “a-b” → “a[b]b” |
| Any of them, in plain-text mode | Nothing special: the replacement is inserted exactly as typed. | “price” | “$1 $&” | “price” → “$1 $&” |
Worked examples
| Task | Settings | Find | Replace with | Text → result |
|---|---|---|---|---|
| Swap two words | Regular expression | “(\w+) (\w+)” | “$2 $1” | “red apple” → “apple red” |
| Change a date from year-first to day-first | Regular expression | “(\d{4})-(\d{2})-(\d{2})” | “$3.$2.$1” | “2026-11-02” → “02.11.2026” |
| Collapse runs of spaces to one | Regular expression | “ {2,}” | “ ” | “a b c” → “a b c” |
| Delete blank lines | Regular expression | “^\n” | “” | “one↵↵two↵↵↵three” → “one↵two↵three” |
| Start every line with “> ” | Regular expression | “^” | “> ” | “one↵two” → “> one↵> two” |
| Strip HTML tags | Regular expression | “<[^>]+>” | “” | “<b>Bold</b> and <i>italic</i>” → “Bold and italic” |
| Replace a symbol that is also regex syntax | Plain text (the default) | “(c)” | “©” | “(c) 2026 Example” → “© 2026 Example” |
| Run two replacements in order | Two pairs, whole word | “colour”, then “grey” | “color”, then “gray” | “grey colour, colourful grey” → “gray color, colourful gray” |
How to find and replace text online
- Paste your text. Replace the example with your own. The text is limited to 1,000,000 characters, and every match is highlighted as you type.
- Type what to find and what to put instead. Fill in “Find” and “Replace with”. Leave the replacement empty to delete every match. Use “Add another pair” to run more replacements, one after the other.
- Choose the options. Turn on Case sensitive to tell “Cat” from “cat”, Whole word to skip matches inside longer words, and Regular expression to search with patterns and use $1 in the replacement.
- Replace all, or go one by one. The result below always shows every match replaced. Pick “One by one” to see each match in turn, then use Next match to skip it or Replace to change it; Undo takes the last replacement back.
- Copy or download the result. Copy the result to the clipboard or download it as a .txt file.
Frequently asked questions
- How do I find and replace text online?
- Paste the text into the first box, type the word or phrase in “Find” and its replacement in “Replace with”. The matches are highlighted at once and the result appears below with every one replaced. Copy it or download it as a .txt file. With the options off the search ignores case and matches inside longer words, exactly like the find box of most text editors.
- What does “Whole word” mean, and does it work for accented and non-Latin text?
- A whole-word match may not be touched on either side by a letter, a combining accent, a digit or an underscore, in any script. So “cat” matches in “cat.” and “cat-1” but not in “catalog” or “cat_1”. The test uses Unicode letter classes rather than the ASCII-only \b, so replacing “café” with “thé” in “un café, des cafés” gives “un thé, des cafés”: the plural “cafés” is left alone, and the same holds for Cyrillic, Greek or Hebrew words. Chinese, Japanese and Thai are written without spaces, so Whole word skips a match that sits inside a run of characters; leave it off for those.
- How do I use $1 and other capture groups in the replacement?
- Turn on Regular expression and put the part you want to keep in parentheses in “Find”. In “Replace with”, $1 is what the first pair of parentheses matched, $2 the second, and so on; $& is the whole match, $<name> is a named group written (?<name>…), and $$ is a literal dollar sign. The table of replacement codes on this page shows each one working. Outside regular expression mode these codes mean nothing and are inserted as typed, so you can safely replace text with “$5”.
- Why does it say “Not a valid regular expression”?
- The pattern could not be compiled, so nothing was changed and the message names the pair at fault. The usual causes are an unmatched parenthesis or bracket, a quantifier with nothing before it (such as a leading *), and a backslash in front of a character that needs none. Patterns here run in JavaScript’s Unicode mode, which only allows a backslash before a symbol like . ( [ or a class such as \d, so \- or \@ outside a character class is rejected: remove the backslash.
- How do I replace a line break or a tab?
- To find a line break, turn on Regular expression and search for \n (\r\n for Windows files); \t finds a tab. The replacement box is plain text, so to insert a line break press Enter in it, and to insert a tab paste one. For example, with Regular expression on, finding \n and replacing it with a comma and a space turns a three-line list into “a, b, c”.
- What happens with a pattern that never finishes?
- Some patterns, such as (a+)+$ on a long run of a’s, make the matching engine retry an astronomical number of ways. Regular expressions here run in a background worker with a two-second limit: if one is still going, the worker is stopped, nothing is replaced, and a message tells you so, while the page stays responsive. Plain-text searches are escaped before matching and cannot run away. The text itself is limited to 1,000,000 characters.
- Is there a limit on the size of the text?
- Yes: 1,000,000 characters, about 1 MB of ordinary text. A longer paste is refused with a message instead of being cut, because a result built from half of your text would be wrong without looking wrong. The same goes for a replacement that would make the text longer than 5,000,000 characters. Highlighting stops at the first 2,000 matches and the preview at 200,000 characters to keep the page fast, but the count and the result always cover everything.
- Does the order of the pairs matter?
- Yes. Pairs run from the first to the last, and each works on the text the one before it produced. Replacing a with b and then b with c turns “ab” into “cc”; in the other order, b with c and then a with b, the same text becomes “bc”. To swap two words, send one of them through a placeholder that appears nowhere else. The “Show pair” menu previews the text that a chosen pair receives.
- How does replacing one by one work?
- Choose “One by one” and the current match is outlined in the highlighted text, with a count such as “Match 2 of 5”. Next match skips it; Replace changes it in your text and moves on. When no match follows, the search continues from the start. Undo last replace restores the text from before your last replacements (up to ten steps), but typing in the text box yourself clears that history. While stepping, only the pair chosen in “Show pair” is used.
- Why did an empty pattern like x* insert text between every letter?
- A pattern that can match nothing, such as x*, ^ or \b, matches at positions rather than characters, and a replacement is inserted at each one. Replacing x* with a hyphen in “abc” makes 4 matches and gives “-a-b-c-”, the same as JavaScript’s own replace. With Regular expression on, ^ matches at the start of every line, which is handy for adding a prefix to each line.
- Can it keep the capital letters when it replaces?
- No. The replacement is always inserted exactly as you typed it, so replacing “cat” with “dog” in “Cat” gives “dog”, not “Dog”. If the case matters, turn on Case sensitive and add one pair per spelling, for example “Cat” to “Dog” and “cat” to “dog”.
- Does anything I paste get sent to a server?
- No request carries your text. The matching and the replacing are done by your browser’s own JavaScript engine, in a background thread of the same page for regular expressions, and the text, the patterns and the result exist only in that page until you reload or close it. The site’s usage statistics, if you allow them, note that a button was pressed and never what was in the boxes.
How it works
In plain-text mode the text to find is escaped so that every character, including . * ( [ and $, matches itself, and the replacement is inserted exactly as typed. In regular expression mode the pattern is used as written and compiled by the browser’s own JavaScript engine with the Unicode flag (u) and the multiline flag (m, so ^ and $ match at every line), plus the ignore-case flag (i) unless Case sensitive is on; the replacement codes $1, $<name>, $&, $`, $' and $$ are expanded by the algorithm in the ECMAScript specification, and the tool’s output is tested against the browser’s own String.replace for every code. Ignoring case uses Unicode simple case folding, so “É” matches “é” and a capital Σ matches σ and the final ς. Whole word wraps the pattern in a check that the character before and after the match is not a letter, a combining mark, a digit or an underscore in any script ((?<![\p{L}\p{M}\p{N}_]) and (?![\p{L}\p{M}\p{N}_])). Matches are found left to right without overlapping; an empty match is replaced like any other and the search then moves on by one whole character, so a letter outside the basic plane is never split. Pairs run in order, each on the previous result. The text may have 1,000,000 characters; longer text, and a result longer than 5,000,000 characters, are refused rather than cut. Regular expressions run in a Web Worker that is stopped after two seconds, so a pattern with catastrophic backtracking cannot freeze the page; plain-text searches cannot backtrack and run directly. The count is exact for any size; only the highlighting is limited, to the first 2,000 matches and 200,000 characters. Nothing is sent to a server.
Sources
More free tools
- Sort Lines AlphabeticallySort text lines A to Z, Z to A, naturally (file2 before file10), by number or length, or shuffle them. Handles big lists and stays in your browser.
- Text CleanerClean pasted text: trim lines, collapse spaces, drop blank lines, join line breaks, straighten smart quotes, strip hidden characters and tags, with counts.
- Regex TesterTest JavaScript regular expressions: highlighted matches, capture groups, replacements with $1 or $<name>. Stops runaway patterns. Runs in your browser.
- Text CompareCompare two texts and see what changed, line by line with changed words highlighted. Ignore case or spacing, copy a unified diff. Stays in your browser.
- Word CounterCount words, characters, sentences and reading time, and check your text against X, LinkedIn, Instagram, SMS and meta description limits.
- Case ConverterConvert text to UPPERCASE, lowercase, Title Case, Sentence case, camelCase, PascalCase, snake_case, kebab-case or CONSTANT_CASE. Stays in your browser.