← The Code Deck
/ deck / lab / regex

Regex visualizer.

Type or paste a regular expression. See it as a railroad diagram, test it live against any input, and read what the pattern actually matches in plain English.

/ /
Parsing…
Railroad diagram
Type a regex above to see its diagram.
Test against input

      
Plain English
Try an example: ISO date email-ish named groups URL host phone IPv4 URL scheme

How it works

The regex is parsed into an AST using regexpp — the same parser ESLint uses internally. Each AST node is mapped to a railroad-diagram primitive (Sequence, Choice, Optional, ZeroOrMore, OneOrMore, Group, Terminal) and the SVG is rendered using Tab Atkins' railroad-diagrams library — the same one used in W3C specs.

The plain-English panel walks the same AST and emits one phrase per node, joined with "then" for sequences and "or" for alternations. Quantifiers are described by the actual {min, max, greedy} values rather than just the surface syntax — so x{2,5} reads as "between 2 and 5 of x" and x*? reads as "zero or more (lazy) of x".

The live tester compiles the source with new RegExp(source, flags) and runs matchAll when the g flag is set; matches are highlighted inline in the test input. The diagram colour-codes built-in groups (terracotta), capture groups (dashed border), and assertions like ^ / $ / \b (green).

Everything runs client-side; the two libraries are loaded once from a CDN as ES modules.

Planned

v0.1 · 2026