Skip to main content

Regex Visualizer

Type a regular expression and see it drawn as a railroad diagram — boxes for literals and classes, containers for groups, branches for alternation, labels for quantifiers. Runs entirely in your browser.

How it works

The tool parses a practical subset of regex syntax — literals, common escapes (\d \w \s .), character classes, capturing and non-capturing groups, alternation, quantifiers (* + ? {n} {n,m}), and anchors — then renders the parse tree as an SVG diagram. Complex constructs like lookahead and backreferences are out of scope: they belong in the engine, not in a picture.

What diagrams are good for

  • Reading other people’s regex: a 40-character pattern becomes a five-second scan
  • Teaching and documentation: a diagram explains (\d{4})-(\d{2})-(\d{2}) better than prose
  • Sharing: screenshots of diagrams travel — the visual is the most shareable form a regex can take

For testing whether the pattern actually matches, pair with the regex tester — visualize to understand, test to verify.