inyourbrowser.com

Regex Replace Tool

Test a JavaScript replacement pattern before it goes into your code. The tool runs String.prototype.replace with your pattern and flags, so $1, $2 and $& behave exactly as they will in your script. All processing runs in your browser.

//
Test string
REPLACE WITH
Result
Enter a pattern and test string above

MODE

Runs entirely in your browser

How it works

The tool uses the browser's native JavaScript RegExp engine. Patterns are compiled with new RegExp(pattern, flags) and run in a Web Worker that is stopped after 2 seconds, so a runaway pattern cannot freeze the page. Invalid patterns show an error message next to the pattern and never crash the page.

Processing runs in your browser

Both the pattern and the test string are processed entirely in your browser. Our servers are not involved at any point.

Related operations

For plain substring swaps without regex, try find and replace. To validate JSON patterns you are matching, use the JSON formatter. For decoding escape sequences in HTML attribute values, see HTML entities.

Frequently asked questions

How do I reference a capture group in the replacement?
Use $1, $2, and so on to reference the first, second, and subsequent capture groups. Use $& to insert the entire match, $` for the text before the match, and $' for the text after.
Does the global flag affect replacements?
Yes. With the g flag every match is replaced. Without it, only the first match in the input is replaced. Use the i flag to make matching case-insensitive.
Can I delete all matches?
Yes. Leave the replacement field empty and add the g flag. Every match is replaced with an empty string, effectively deleting all occurrences.
Is my text sent to a server?
All processing runs in your browser using the native JavaScript RegExp engine. Our servers are not involved at any point.

Last reviewed September 30, 2026

Other pages for this tool

Related tools

Find & replace
Find and replace text with plain search or regular expressions. Supports case-sensitive and whole-word matching.
SQL formatter
Beautify and format SQL queries. Supports MySQL, PostgreSQL, T-SQL and standard SQL.
Cron expression explainer
Parse any cron schedule into plain English and see the next run times. Fully in-browser.