devtools

Find and Replace Text

Find and replace text online with literal or regex search, case-insensitive matching, and $1 capture groups. Replace all or the first match, privately.

Runs entirely in your browser — your data never leaves your device.

How to use Find and Replace Text

What it does & when you need it

Sometimes you need to swap one string for another across a whole block of text without opening an editor or writing a sed command. This tool does exactly that: paste your text, type what to find and what to replace it with, and every match is swapped instantly. It works in plain-text mode for a straight literal swap, or in regular-expression mode when you need patterns and capture groups.

It is useful for renaming a variable throughout a snippet, redacting a recurring token, reformatting a list, fixing a repeated typo, or restructuring data with a pattern. Everything happens in your browser, so the text — and whatever you are replacing in it — never leaves your machine.

How to use

  1. Paste your text into the input buffer, press Sample for an example, or Upload a file.
  2. Type your search term in Find and the replacement in Replace with. Toggle Regex for pattern matching, Ignore case to match regardless of capitalisation, and Replace all to switch between every match and only the first.
  3. The output buffer updates live, and its status bar shows how many replacements were made. Press Copy result or Ctrl/Cmd + Enter.

Things worth knowing

Literal mode is truly literal. Special regex characters like ., *, and ? are escaped for you, so searching for a.b matches only those three characters and not "axb". A dollar sign in your replacement stays a dollar sign rather than being read as a capture reference.

Regex mode unlocks capture groups. Turn on Regex and your search becomes a JavaScript regular expression. Reference captured groups in the replacement with $1, $2, and so on — for example, find (\w+)@(\w+) and replace with $2.$1 to flip the two halves around an at-sign. If the pattern does not compile, the tool shows the error instead of silently doing nothing.

Matching is case-sensitive by default. Enable Ignore case to add the regular-expression i flag, so "Foo", "FOO", and "foo" all match the same search.

Working with lists or code? Pair this with the line sorter, the diff checker, or the whitespace cleaner.

Examples

Rename every occurrence

The fox jumped. The fox ran. The fox slept.

Find fox and replace with cat to swap all three at once with Replace all on.

Regex capture groups

user@example.com

In Regex mode, find (\w+)@(\w+) and replace with $2.$1 to reorder around the at-sign.

Literal special characters

Released version 1.0.0 today.

Literal mode treats the dots as dots, so searching for 1.0 never matches 120.

Frequently asked questions

How do I replace every occurrence at once?

Type your search in Find and the new text in Replace with, and keep Replace all enabled. Every match is swapped in a single pass, and the output status bar reports how many replacements were made. Turn Replace all off to change only the first match.

What is the difference between literal and regex mode?

In literal mode the search is treated as plain text, and special characters like a dot or asterisk are escaped for you — so searching for "a.b" matches only those three characters, not "axb". Turn on Regex to treat the search as a JavaScript regular expression with full pattern matching.

How do I use capture groups in the replacement?

Switch on Regex, wrap parts of your pattern in parentheses to capture them, and reference them in the replacement with $1, $2, and so on. For example, find (\w+)@(\w+) and replace with $2.$1 to swap the two halves around an at-sign. In literal mode a $ stays a literal dollar sign.

What happens if my regular expression is invalid?

The tool shows the compiler error message in the output panel and leaves your text unchanged, rather than silently doing nothing. Fix the pattern — often an unbalanced parenthesis or bracket — and the replacement runs again as you type.

Is my text uploaded to a server?

No. All searching and replacing happens locally in your browser, so the text and whatever you are replacing in it never leave your machine. It also works offline once loaded.