Regex Tester & Debugger
Test patterns, inspect groups and preview replacements. Free, and runs entirely in your browser — nothing you enter is uploaded or stored.
About Regex Tester
Write a pattern, tick the flags, and every match in the test string is highlighted in place — neighbouring matches in alternating shades so they stay apart — with a table of each match, where it starts, and what every capture group caught, named groups included.
Underneath sits the part that turns a pattern from a wall of punctuation into something readable: the expression is taken apart token by token and explained in words, indented to follow its own nesting. (?<=\b) is a look-behind, [^a-z0-9_] is any character that is not a letter, a digit or an underscore, {2,5} is between two and five times. It is the fastest way to read someone else's regular expression, or to find out why yours does not mean what you thought.
Patterns that are known to go wrong are called out: a repeated group that itself repeats is the shape behind most regular-expression denial of service, and two greedy wildcards in a row make the engine try every split between them. Add a replacement and the substitution is previewed before you run it against anything real.
This uses the browser's own regular expression engine, so what you see here is what JavaScript will do — including its specific behaviour for lookbehind, named groups and Unicode escapes. Patterns from Python, PCRE or Go may need adjusting.
Where it helps
- Explains the pattern token by token, indented to follow its nesting — the quickest way to read a regular expression you did not write.
- Matches and capture groups are shown together in a table, named groups included, so you can see what each group caught.
- Replacement preview with
$1style references, before you touch production data. - Every match is listed with its position in the string, so you can see what was skipped.
- Everything is local — test against real log lines without uploading them.
Limits
- JavaScript flavour only; PCRE features such as atomic groups and recursion are unavailable.
- A catastrophically backtracking pattern will hang this page just as it would hang your server — the warnings point at the shapes that cause it, but they cannot catch every one.
- Highlighting shows matches, not why a pattern failed to match, and only the first 500 matches are listed.
- Regular expressions cannot parse nested structures — HTML and JSON need real parsers.
Frequently asked questions
Do I need the g flag here?
It is ticked by default, and applied anyway when nothing else would find more than one match, so you always see every match. Your own code still needs it, which is the usual reason a pattern behaves differently there.
Is the explanation the engine's own reading of the pattern?
It is a separate reading, written to be understood rather than executed. The matching itself is done by the browser's engine, so where the two could ever disagree, the matches are the truth.
What do the common flags do?
g finds every match, i ignores case, m makes ^ and $ match at line boundaries, s lets . match newlines, and u enables full Unicode handling.
Why does my pattern work in Python but not here?
Flavours differ. (?P<name>…) becomes (?<name>…), and PCRE-specific constructs have no JavaScript equivalent.
How do I reference a capture group in the replacement?
$1, $2 and so on by position, or $<name> for a named group. $& inserts the whole match.
Related tools
- Text Comparison — Line-by-line diff of two blocks of text
- Duplicate Remover — Remove, isolate or list duplicate lines
- Case Converter — Switch between sentence, camel, snake and other cases
- JavaScript Formatter — Re-indent JavaScript and TypeScript source
- HTML Formatter — Indent and tidy HTML markup
- CSS Formatter — Format stylesheets with consistent indentation
More Web Development tools
- HTML Formatter — Indent and tidy HTML markup
- CSS Formatter — Format stylesheets with consistent indentation
- JavaScript Formatter — Re-indent JavaScript and TypeScript source
- SCSS/SASS Formatter — Format SCSS syntax and nested rules
- TypeScript Formatter — Format TypeScript source code
- SQL Formatter — Format SQL statements with dialect selection
- SQL Minifier — Collapse formatted SQL into compact text
- CSS Unit Converter — px, rem, em, percentages and viewport units, with a preview
- Query String Parser and Builder — Convert query strings into editable key-value data
- CSP Generator — Build a Content-Security-Policy, or check one, and write it for your server or framework
- CORS Generator — Write CORS configuration for nginx, Express, Go, Django, ASP.NET, Spring and more, and test an origin against it
- cURL Builder — Build an HTTP request and get it as curl, JavaScript, TypeScript, Go, Python, PHP, C#, Java and more
- Minifier — Shrink CSS, HTML or JavaScript
- Flexbox Playground — Try every flex property and read the CSS back
- CSS Grid Playground — Build a grid template and see the tracks it makes
- Responsive Viewport Tester — Render your markup at phone, tablet and desktop widths
- SVG Path Viewer — Draw path data and read back what it contains
- SVG to CSS Converter — Turn an SVG into a data URI for CSS or an img tag
- OAuth 2.0 / OIDC Helper — PKCE verifiers and challenges, state, nonce, and checking what came back
- User-Agent Parser — Identify the browser, engine, operating system and device behind a User-Agent string
- HTTP Status Codes — Look up what a status code means, when to send it, and whether it is cached or safe to retry
- HTML to JSX — Convert HTML and SVG markup into JSX for React, with styles, attributes and whitespace handled
- Semver Checker — Test versions against npm ranges, sort them by precedence, and see what each bump produces
- Cookie Parser and Builder — Read Set-Cookie and Cookie headers, check them against browser rules, and write one for your framework