Tools/RegEx Railroad Diagram Generator

RegEx Railroad Diagram Generator

Client-Side · SVG Engine
Presets:
Flags:
//
● Full Match
100%
^Start of line[a-zA-Z0-9._%+-]Class [a-zA-Z0-9._%+-]++ (greedy)@"@"[a-zA-Z0-9.-]Class [a-zA-Z0-9.-]++ (greedy)\.Escaped '.'[a-zA-Z]Class [a-zA-Z]{2,}Repeat {2,}$End of line── track 1 ──── track 2 ──
Client-Side Engine · Interactive Railroad Tracer · ReDoS Analyzer
ECMAScript RegExp · 100% In-Browser

How the Railroad Diagram Works

A railroad diagram (also called a syntax diagram or flowchart diagram) represents a regular expression as a series of connected nodes — one per token — laid out left to right. Reading the diagram from left to right describes exactly which characters or constructs the engine matches at each step.

Client-Side Lexer

The pattern is tokenized entirely in your browser using a hand-written regex lexer. It identifies anchors, character classes, quantifiers, capture groups, lookaheads, lookbehinds, named groups, alternations, and backreferences — no server or third-party library involved.

SVG Flow Generator

Each token is rendered as a labeled node in an SVG canvas. Nodes are color-coded by category, connected by directional lines, and wrapped into rows automatically. The diagram can be exported as a standalone SVG file for documentation and code review.

Token Categories & Color Reference

ColorCategoryExample TokensDescription
Anchors & Boundaries^ $ \b \BZero-width assertions — match a position, not a character
Character Classes\d \w \s [a-z] .Sets or ranges of characters the engine can match
Literals"hello" \n \tExact character sequences or escape sequences
Quantifiers (dashed border)* + ? {2,4} *?How many times the preceding element can repeat
Capture Groups( ) (?:) (?<name>)Capture, non-capture, and named groups with numeric badge
Lookahead/Lookbehind(?=) (?<=)Positive lookahead and lookbehind zero-width assertions
Negative Assertions(?!) (?<!)Negative lookahead and lookbehind assertions
Alternation|OR branch — matches either left or right sub-expression
Backreferences\1 \2References to a previously captured group

When to Use a Railroad Diagram for Regex Debugging

Code Review

Export the diagram as SVG and embed it in pull request comments to explain complex patterns to reviewers who may not be regex experts.

Debugging Failures

When a pattern fails to match, walking each node left to right reveals which token is the boundary that the input stops satisfying.

Learning Regex

New team members can read the diagram like a flowchart instead of parsing dense regex syntax — lowering the learning curve significantly.

Client-Side Processing — Your Patterns Stay Private

The lexer, layout engine, and SVG renderer all run inside your browser's JavaScript sandbox. No pattern or test string is transmitted to any server, analytics endpoint, or third-party service.

This matters when working with sensitive data: authentication token patterns, PII extraction regexes, internal log format matchers, or proprietary parsing rules — all remain on your device.

Open & Client-Side

Built for Daily Developer Workflows

Free, browser-based utilities that format, validate, and convert data locally. No accounts, no ads, no backend data collection.