Regex Visualizer
Turn a JavaScript regular expression into a railroad diagram you can read at a glance, and export it as SVG or PNG.
Railroad diagram
Legend
How to use the regex visualizer
- Paste a JavaScript regular expression between the slashes — or pick one of the examples to see the shape of a real pattern.
- Read the railroad diagram left to right: boxes are things that must match, stacked branches are alternatives, and a loop arrow underneath means “repeat”.
- Export the diagram as SVG for docs or a pull request, or as PNG for a slide or a chat message.
FAQ
How do I read a railroad diagram?
Follow the line from the green start dot to the red end dot. Every box you pass through has to match, in that order. Where the line splits into stacked rows, any one of those rows will do — that is an | alternation. A line that curves back underneath a box is a repetition, and its label says how many times. A line that bypasses a box above it means the box is optional.
Which syntax is supported?
ECMAScript patterns: literals, character classes, ., escapes, anchors, groups (capturing, named and non-capturing), alternation, all quantifiers including lazy ones, back-references, lookahead and lookbehind, and \p{…} Unicode properties. Very new set notation from the v flag may be drawn as a single box rather than expanded.
Does my pattern get uploaded?
No. Parsing and drawing happen in your browser, and the SVG or PNG is generated locally too. Nothing about the pattern leaves the page.