DevKits

Interactive visualizer

Regex Visualizer — Break Down Any Regular Expression

Paste a regular expression and see every token color-coded and explained. Live match highlighting, capture groups, and full syntax support for JavaScript regex.

Last updated:

Examples:
//

Breakdown

^([a-zA-Z0-9._%+-]+)@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$

Token-by-token explanation

TokenKindMeaning
^Anchorstart of string (or line with m flag)
(Groupcapture group start
[a-zA-Z0-9._%+-]Character classany single character in the set [a-zA-Z0-9._%+-]
+Quantifierrepeat the previous token one or more times, greedy
)Group closegroup end
@Literalliteral character "@"
(Groupcapture group start
[a-zA-Z0-9.-]Character classany single character in the set [a-zA-Z0-9.-]
+Quantifierrepeat the previous token one or more times, greedy
\.Escaped literalescaped literal "."
[a-zA-Z]Character classany single character in the set [a-zA-Z]
{2,}Quantifierrepeat the previous token 2, time(s)
)Group closegroup end
$Anchorend of string (or line with m flag)

Live match preview

0 matches
No matches

Legend

LiteralMeta characterAnchorCharacter classGroupAlternationQuantifierEscaped literalBack-referenceAssertionModifier

How this visualizer works

The regex is scanned left-to-right and each construct — anchors, character classes, groups, quantifiers, back-references, and look-arounds — is emitted as a labelled token. Nesting is preserved via indentation so you can see at a glance which quantifier applies to which group. Everything happens client-side; your pattern is never sent to a server.

Reading the color-coded tokens

  • Sky-blue = meta character (\d, \w, \s, .)
  • Purple = anchor (^, $, \b, \B)
  • Emerald = character class ([abc], [^0-9])
  • Amber = capture / non-capturing group ( )
  • Rose = quantifier (*, +, ?, {n,m})
  • Pink = alternation (|)
  • Fuchsia = look-ahead / look-behind assertion
  • Indigo = back-reference (\1, \k<name>)

Common pitfalls this visualizer helps catch

  • Greedy vs lazy quantifiers — the visualizer marks lazy variants like *? +? ?? explicitly.
  • Forgetting to escape a literal dot inside a character class (they're already literal).
  • Confusing (?:x) non-capturing with (?=x) look-ahead — different colors make the distinction obvious.
  • Anchors inside character classes: [^abc] means "not a/b/c", not "start of line".

Frequently Asked Questions

Which regex flavor does this visualizer support?

JavaScript (ECMAScript) regex, matching what modern browsers execute. Named capture groups, look-ahead, and look-behind are supported. PCRE-only features (recursion, atomic groups, possessive quantifiers) are not.

Is my regex sent to a server?

No. Parsing, tokenisation, and match testing all run locally in JavaScript. Nothing is uploaded and no analytics track the content of your patterns.

Why is my expression valid but the token list looks wrong?

The tokenizer is intentionally simple and does not simulate the NFA — it explains structure, not runtime behaviour. Use the live match preview to confirm your expression matches what you expect on real input.

How is this different from your Regex Tester tool?

The tester is a debugging playground (matches, groups, flags). This visualizer focuses on teaching — every part of the pattern is annotated with plain-English explanations so you can understand a regex before running it.

Other visualizers