Find and Replace Text
Find and replace text with optional regex, case, and multiline matching
Input
About
Find and replace text in a document. Toggle literal vs regex matching, case sensitivity, and multiline mode. The number of replacements is shown live. Everything runs in your browser; nothing is uploaded.
Examples
Literal find and replace
text: The quick brown fox jumps over the lazy dog
find: fox
replace: wolfThe quick brown wolf jumps over the lazy dog
Matches: 1Every occurrence of the literal string 'fox' is replaced with 'wolf'. The count reflects the number of replacements made.
Regex replace with capture groups
text: user-01: Alice, user-02: Bob, user-03: Carol
find: user-(d+): (w+)
replace: [$1] $2
flags: g[01] Alice, [02] Bob, [03] Carol
Matches: 3$1 is the first capture group (the number) and $2 is the second (the name). Each match is reformatted according to the replacement pattern.
About this tool
Find & Replace is a staple of any text editor, but this tool goes further: it supports both literal and regex modes, live match counts, and the full range of JavaScript replace() patterns including $1/$& capture groups in regex mode. It is a quick way to preview a global substitution without opening a full IDE.
In literal mode the replacement string is treated verbatim — $ is not special. In regex mode, the replacement string honours $1, $2… for numbered groups, $<name> for named groups, $& for the whole match, and $$ for a literal $. An invalid regex is caught immediately and an error is shown.
How to use this tool
Paste your text
Drop the text you want to search and replace in. The search and replacement inputs are separate so you can iterate without retyping.
Choose search mode
Toggle Literal or Regex. Literal mode does a straight string match; Regex mode interprets the Find input as a JavaScript regular expression with the chosen flags (case-sensitive, multiline).
Preview and copy
The match count updates live as you type. Click Copy to grab the replaced text.
Use cases
Batch-renaming keys in a JSON file
Use a regex to match and rename object keys across a large JSON document, with a live preview of every replacement before committing.
Reformatting log lines
Strip timestamps, extract fields, or normalise log output with a regex that captures and rearranges the parts you care about.
Wrapping text in markup
In literal mode, wrap every occurrence of a string in HTML tags or Markdown syntax without needing a full editor.
Common mistakes
Mistake:Forgetting the global flag (g) for a regex.
Fix:Without the g flag, only the first match is replaced. For a global substitution, always enable the 'g' flag or use the regex flag toggle in the UI.
Mistake:Treating the replacement string as a regex.
Fix:In literal mode the replacement is verbatim text. If you type $1 in the replacement, it appears literally — not as the captured group. Switch to Regex mode for capture group support.
Mistake:Writing a regex that matches too much.
Fix:A regex like .* is greedy and will consume as much as possible. Use .*? (non-greedy) or a more specific character class to avoid over-matching.
Frequently asked questions
What happens if my regex is invalid?
An invalid regex throws a SyntaxError that is caught and displayed as an error message below the Find input. The replacement does not run until the regex is corrected.
Does the replace work with Unicode characters?
Yes. JavaScript's native String.prototype.replace() handles Unicode characters correctly, including emoji, accented letters, and characters outside the BMP. The regex engine also supports the u flag for full Unicode property escapes.
Can I use named capture groups in regex replace?
Yes. In regex mode, $<name> refers to a named capture group (?<name>...) in the pattern, just like in JavaScript's native replace().
Is my text uploaded anywhere?
No. All find and replace operations run entirely in your browser; the input is never transmitted or stored.
Related guides
References & standards
Related tools
Anagram Solver & Palindrome
Normalize text for palindrome checks and privacy-preserving anagram analysis.
Binary Text Translator
Convert text to binary or hex bytes and decode it back
Case Converter & Text Formatter
Convert text between 14 different case formats including camelCase, snake_case, kebab-case with batch processing and advanced options
Character Frequency Analyzer
Count character, letter and word frequencies for text analysis
HTML to Markdown Converter
Paste HTML and get clean Markdown. Configurable heading style, bullet marker, and code block style — all processed locally in your browser.
Keyword Extractor
TF-IDF keyword extraction from any document — ranked terms with scores