🛤️Regex Visualizer - Railroad Diagrams and Plain Explanations
Long regular expressions are hard to read at a glance. Paste one in — the /pattern/flags form works too — and a built-in parser reads it with JavaScript syntax and draws a railroad diagram: follow the line from left to right to see how matching proceeds, where forks mean one of several alternatives, a bypass above means optional, and an arrowed loop below means repetition, labeled with the count and whether it is lazy. Capturing groups, named groups and lookarounds are boxed and labeled, and character classes list every member. The explanation below translates each part into plain words, and hovering over the diagram or the explanation highlights the same span in your pattern. Supported syntax includes alternation, capturing, named and non-capturing groups, positive and negative lookahead and lookbehind, (?i:…) modifier groups, greedy and lazy quantifiers including {m,n}, character classes and escapes, the ^ $ \b \B anchors, back-references \1 and \k<name>, Unicode property escapes \p{…} and every flag d g i m s u v y — including v-mode nested classes with && and -- operators. Syntax errors point to the offending position, and diagrams export as SVG or high-resolution PNG for docs and code reviews.
Free · No sign-up · Runs in your browserLast updated:
How to use Regex Visualizer
- 1Enter a regex and tick its flags, or pick an example
- 2Read the railroad diagram and the explanation, hovering any part to see it in the pattern
- 3Export SVG or PNG, or open the regex tester to try it on real text
FAQ
- How do I read a railroad diagram?
- Start at the hollow circle on the left and follow the line to the filled circle on the right; each box you pass must match in turn. Where the line forks, any one branch can match. A line bypassing a box from above means that part is optional, and an arrowed loop below a box means it can repeat, labeled with the count (such as “2–5 times”) and whether it is lazy. Dashed boxes are zero-width assertions such as lookarounds; solid boxes are capturing groups.
- Which regex syntax is supported?
- The parser follows JavaScript (ECMAScript 2025): alternation, capturing, named and non-capturing groups, all four lookarounds, (?i:…) modifier groups, every quantifier, character classes, \d \w \s escapes, \x \u \u{…} \c character escapes, anchors, back-references, \p{…} Unicode properties, and v-mode nested classes with &&, -- and \q{…}. Without the u flag it also follows the browser’s lenient rules for a lone {, or \8 beyond the group count, and tells you when it does.
- Why might Python or Java treat my regex differently?
- Regex dialects differ. Python writes named groups as (?P<name>…) and supports \A and \Z, while Java and PCRE support possessive quantifiers like a++ and atomic groups (?>…), none of which exist in JavaScript. This tool parses strictly as JavaScript, and validity is checked with your browser’s own RegExp engine.
- Is my regex uploaded anywhere?
- No. Parsing, drawing and exporting all happen in your browser; neither the pattern nor the images leave your computer.