Regex

Regex Explainer

Paste a pattern to see it broken down token by token in plain English, with nested groups shown as indentation. Runs entirely in your browser; nothing you type is ever sent anywhere.

//
Enter a pattern above to break it down token by token.

Quick Learn

Reading someone else's regex — or your own from six months ago — usually means squinting at a wall of symbols and mentally simulating what each piece does. A pattern like ^(?<user>[\w.+-]+)@(?<domain>[\w-]+\.[a-zA-Z]{2,})$ is really just several small, ordinary rules stacked together: start of string, one or more word/dot/plus/dash characters, an @, more characters, a literal dot, then letters — the density is what makes it hard to read, not the individual pieces.

This tool walks a pattern left to right and explains each piece in plain English, using JavaScript's own regex parser to catch invalid syntax first. Groups are indented under the parenthesis that opens them, so nested structure is visible at a glance instead of buried in brackets. Everything runs locally in your browser.

Best Practices

  • •Read top to bottom, not left to right in your head — the token list already did the left-to-right parsing for you; scanning it top to bottom is usually faster than re-parsing the raw pattern yourself.
  • •Pay attention to which token a quantifier attached to — a common source of "why does this match more than I expected" is a quantifier landing on a single character instead of the group you meant it to repeat.
  • •If a pattern you wrote doesn't explain the way you expected, that's often the bug itself — trust the breakdown over your mental model of what you thought you wrote.
  • •Named groups explain themselves ("a named capturing group 'user'") far better than numbered ones — worth converting a pattern's groups to named ones before sharing it with someone else.

More Regex Tools

See all Regex tools

Frequently Asked Questions

Is my pattern uploaded anywhere?

No. The pattern is parsed and explained entirely in your browser — nothing you type is sent to a server or stored anywhere.

How is a pattern's structure checked before explaining it?

This tool first tries to construct the pattern with JavaScript's own RegExp() — the same validation the Tester and Replace tools use — so a syntactically invalid pattern is rejected with the browser's own error message before any explanation is attempted.

Why is a run of ordinary letters shown as one token instead of one per letter?

Consecutive plain characters are merged into a single "literal text" token for readability, unless a quantifier applies to just the last one of them — in that case, the last character is shown separately so the quantifier's target is unambiguous.

Does the indentation mean anything?

Yes — each level of indentation is one level of parentheses. A token indented under a group's opening parenthesis is part of what that group matches, which makes nested groups and lookarounds easier to trace than counting brackets by eye.

Does this explain every possible regex feature?

It covers the ECMAScript (JavaScript) regex features used in the overwhelming majority of real patterns: character classes, anchors, quantifiers, groups (capturing, non-capturing, named), lookaround, alternation, and common escapes. A handful of exotic edge cases in Unicode property escapes may show a more generic description.

Want the engineering deep-dives behind tools like this one?