JavaScript Regex Tester — Test and Debug JS Regular Expressions Online
FreeTest JavaScript regular expressions live with match highlighting, capture groups, and flag support. Free, runs in your browser using the JS RegExp engine.
What's next
Settings guide
JavaScript regex flags:
- ·`g` (global) — Find all matches, not just the first. Required for
matchAll()and global.replace(). - ·`i` (case-insensitive) —
/hello/imatches "Hello", "HELLO", "hElLo". - ·`m` (multiline) —
^and$match the start/end of each line, not just the whole string. - ·`s` (dotAll) —
.matches newlines (\n). Withouts,.skips newline characters. - ·`u` (unicode) — Enables full Unicode matching. Required for matching Unicode code points above U+FFFF and Unicode property escapes (
\p{Letter}). - ·`d` (indices) — Adds
indicesarray to match result with start/end positions for each group.
Named capture groups: JavaScript (ES2018+) supports (?<name>...) syntax. Named groups appear in match.groups.name and can be used in replacement strings as $<name>.
Format comparison
JavaScript RegExp vs Python re module: The biggest syntax differences: Python uses (?P<name>...) for named groups (JS uses (?<name>...)), Python uses re.VERBOSE for comments in patterns (JS has no equivalent), and Python's re.match() only matches at the start of the string (JS .match() searches the whole string). Test your patterns in the language that will run them.
Online tester vs browser DevTools console: DevTools console lets you test regex with /pattern/flags.test("string") but shows only true/false without match highlighting. This tester visualises every match, group, and position — significantly faster for complex pattern development.
How it works
Compile the pattern
The regex pattern and flags are compiled using JavaScript's native RegExp constructor — the same engine that runs in V8 (Chrome, Node.js), SpiderMonkey (Firefox), and JavaScriptCore (Safari).
Execute against test string
matchAll() is called with the global flag, or exec() iteratively for non-global patterns. Every match position, length, and capture group value is recorded.
Highlight and annotate
Matching substrings are highlighted in the test string. Capture groups are annotated by index and name. Non-matching regions are shown in neutral colour.
Generate code snippets
Ready-to-use JavaScript code is generated: String.prototype.match(), matchAll(), replace(), and test() calls using your exact pattern and flags. Copy directly into your codebase.
About this format
JavaScript's `RegExp` engine has specific syntax, flags, and behaviours that differ from Python, PHP, and other languages. Testing a regex against a real string with the actual JavaScript engine — not a generic regex parser — ensures what you test is exactly what runs in production.
Write your pattern, select your flags, and enter your test string. All matches are highlighted, capture groups are labelled by name or index, and match count is shown. The tool generates the corresponding `String.prototype.match()`, `.replace()`, and `.test()` code snippets ready to paste into your JavaScript.