Free Find and Replace Online
Find and replace text in bulk. Supports regular expressions, case-insensitive matching, and multiple replacements. 100% client-side — your text stays private.
What does find and replace do? Find and replace scans a body of text for every occurrence of a search term and substitutes a different string for it. In literal mode the term is matched character for character; in regex mode it is compiled as a regular expression, so \d{4} matches any four digits and $1 in the replacement inserts whatever the first capture group captured. The whole text is rewritten in a single pass.
How to Use the Find and Replace Tool
- Paste the text you want to change — Drop the document, log or code block into the input panel on the left. The original is never overwritten by Replace All, so you can keep tweaking the pattern and compare the two panels.
- Fill in a find/replace pair — Type what to look for and what to put in its place. Leaving the replace field empty deletes every match, which is the quickest way to strip a repeated prefix such as a log timestamp.
- Add more pairs if you need them — + Add Pair adds another row. Pairs run top to bottom and each one operates on the output of the pair above it, so the order matters whenever one rule can produce text that a later rule also matches.
-
Choose literal or regex matching — Leave Regex off and the search term is matched exactly, punctuation included — special characters are escaped for you. Turn it on for patterns such as
\d+or\s{2,}, with$1backreferences available in the replacement field. - Check the two counters — Matches Found and Replacements Made update as you type. If both stay at zero the pattern never matched — the usual causes are case sensitivity and having Regex set the opposite way from what you intended.
-
Copy the result, or save the pairs — Copy takes the output to your clipboard. Export downloads your pairs as
find-replace-pairs.jsonand Import loads that file back, so a recurring cleanup becomes a two-click job.
How Find and Replace Works
Every search term, literal or not, ends up as a JavaScript RegExp object. In literal mode the term is first passed through an escaping step that puts a backslash in front of each regex metacharacter, so a search for price (USD) or a.b matches those characters exactly instead of being read as a group or a wildcard. In regex mode the escaping is skipped and your text is compiled as written.
The Case-insensitive checkbox adds the i flag. The g flag is always present for Replace All, which is why every occurrence is rewritten rather than just the first. Whole word wraps the escaped term in \b word-boundary anchors so that searching for cat leaves category and concatenate alone — note that this wrapping is applied to literal searches only, so in regex mode you should write the \b anchors into the pattern yourself.
Pairs are applied in sequence, not in parallel. The first pair runs against your input, the second runs against the result of the first, and so on down the list. That is useful for staged cleanups but it also means a later rule can act on text an earlier rule produced. If you replace colour with color and then replace color with hue, both spellings end up as hue. When two rules can interfere, reorder them or run them as two separate passes using the Copy button in between.
If a pattern fails to compile — an unmatched bracket or a stray quantifier — that pair is skipped silently and the text passes through untouched. There is no error message, so an output identical to the input is the signal that your regex is malformed. The Regex Tester reports the actual syntax error and is the faster place to debug a pattern before bringing it back here.
Replace All versus Replace First
Replace All is non-destructive: it reads the input panel, applies every pair with the global flag, and writes the result to the output panel only. Your original text stays where it is, so you can adjust a pattern and watch the output change. Replace First and Replace Next behave differently — they apply the first matching pair once, without the global flag, and then write the result back into the input panel so the next click continues from there. That stepping motion is what Undo reverses: it restores the snapshot taken before the last single-step replacement. Because Replace All never modifies the input, there is nothing for Undo to roll back after it.
Regular Expression Reference
These are the constructs that cover most day-to-day replacements. They follow the JavaScript regular-expression dialect, which is close to PCRE for everyday patterns but not identical to it.
| Pattern | Matches | Example |
|---|---|---|
\d | Any digit, 0 to 9 | \d{4} finds 2024 |
\w | Letter, digit or underscore | \w+ finds order_12 |
\s | Space, tab or newline | \s{2,} finds runs of two or more spaces |
. | Any character except a newline | a.c finds abc and a-c |
[abc] | Any one of the listed characters | [aeiou] finds a single vowel |
[^abc] | Any character not listed | [^0-9] finds a non-digit |
* + ? | Zero or more, one or more, optional | colou?r finds both spellings |
{n} {n,m} | Exactly n, or between n and m | \d{3,4} finds a 3- or 4-digit number |
\b | A word boundary | \bcat\b skips category |
( ) | Capture group, recalled as $1 | (\w+)@(\w+) captures both halves |
(?: ) | Group without capturing | (?:Mr|Ms) groups without using a number |
| | Either the left side or the right | cat|dog finds either word |
The multiline flag is not applied, so ^ and $ anchor to the start and end of the entire text rather than of each line. To work line by line, match the newline yourself with \n or \r?\n. Also note that the replacement field is inserted literally apart from $1-style backreferences — typing \n there produces the two characters backslash and n, not a line break.
Replacement Recipes
Each row below is a complete pair you can copy into the fields. The Mode column says whether the Regex checkbox needs to be on.
| Goal | Mode | Find | Replace with |
|---|---|---|---|
| Collapse runs of spaces into one | Regex | \s{2,} | a single space |
| Turn a list into one comma-separated line | Regex | \r?\n | , |
| Keep only the domain from each email | Regex | .*@(.+) | $1 |
| Flip Last, First into First Last | Regex | (\w+), (\w+) | $2 $1 |
| Wrap every word in a span | Regex | \b(\w+)\b | <span>$1</span> |
| Strip a repeated log prefix | Literal | [INFO] | leave empty |
| Rename a variable without touching longer names | Literal + Whole word | id | userId |
Frequently Asked Questions
A regular expression is a small pattern language for describing text rather than spelling it out. \d+ means one or more digits, \s{2,} means a run of at least two whitespace characters, and \b(\w+), (\w+)\b captures two words separated by a comma. This tool uses the JavaScript regex dialect, which is close to PCRE for everyday patterns. Turn the Regex checkbox off if you want your search treated as ordinary text.
Whole word wraps your search term in \b word-boundary anchors, and that wrapping is applied to literal searches only. If the Regex checkbox is also on, the option has no effect and you need to write the anchors yourself: search for \bcat\b rather than cat. Word boundaries sit between a word character and a non-word character, so a term that starts or ends with punctuation may never match.
Undo restores the snapshot taken before the last Replace First or Replace Next click, because those two write their result back into the input panel. Replace All is non-destructive — it only writes to the output panel and leaves your input untouched — so there is nothing for Undo to roll back after it. To reverse a Replace All, edit or clear the find/replace pair and the output recalculates from the original text.
Replace All applies every pair to every match in one pass and shows the result in the output panel. Replace First applies only the first pair that matches, only to its first match, then moves that partially edited text into the input panel so you can step through the document one change at a time. Replace Next does exactly the same thing as Replace First. Use All for bulk edits and First when you want to inspect each change.
Wrap the part you want to keep in parentheses and refer to it as $1, $2 and so on in the replacement field, numbered by opening parenthesis from left to right. Finding (\w+), (\w+) and replacing with $2 $1 converts Smith, Jane into Jane Smith. Use $& to insert the whole match, and $$ to output a literal dollar sign.
Pairs run in order, each on the output of the one before it, rather than all against the original text. Replacing cat with dog in the first row and dog with fox in the second turns every original cat into a fox. Either reorder the rows so the rules cannot cascade, or pick an intermediate placeholder that does not occur in your text and swap it out in a later row.
An invalid regular expression is caught and skipped silently, so the pair does nothing and the output is identical to the input. An unclosed bracket or parenthesis is the usual cause. Paste the pattern into the Regex Tester, which reports the actual syntax error. If the pattern is valid, check whether the multiline behavior you expect is the problem: ^ and $ anchor to the whole text, not to each line.
No. Matching and replacing run in JavaScript in your own tab, and Export builds the JSON file locally with a Blob rather than sending anything to a server. One caveat: your input text and the option settings are written into the page URL so a working state can be bookmarked, so avoid sharing the link if the text contains anything confidential.
Use Cases
Renaming a Variable in a Code Snippet
Rename id to userId across a file with Whole word on, so validId and idType are left alone instead of being silently corrupted.
Repointing Links After a Domain Move
A site moved from a staging host to production. One literal pair swaps the old origin for the new one across an exported page of HTML without touching the paths.
Filling a Mail-Merge Template by Hand
Load a saved set of pairs that map every placeholder — company, contact name, renewal date — to this customer's values, then export the pairs to reuse for the next one.
Stripping Noise From a Log Dump
Delete the repeated timestamp and severity prefix from thousands of log lines by leaving the replace field empty, leaving only the messages you actually need to read.
Reshaping a Column of Names
Convert a pasted column of Last, First entries into First Last with a single capture-group pattern, instead of retyping several hundred rows.