Utilo

Regex Visualizer

Visualize regular expressions as railroad diagrams, read a plain-language explanation of every token, test matches and copy ready-to-use code for JavaScript, Python, Go, Java, C#, PHP and Rust.

What this regex visualizer does

Regular expressions are write-only for most people: easy to type, hard to read a week later. This tool parses your pattern into a syntax tree and shows it three ways. A railroad diagram draws the pattern as a track you can follow from left to right, with branches for alternation, loops for repetition and labeled boxes for groups. A plain-language explanation walks through every token ("one or more digits", "named group year", "not followed by"). And code snippets show how to use the exact pattern with the correct escaping in JavaScript, Python, Go, Java, C#, PHP and Rust. A live test string highlights matches as you type.

How to use it

  1. Type or paste a pattern. You can include slashes and flags like /^\d{4}-\d{2}$/gm or enter the flags separately.
  2. Follow the railroad diagram to see the overall shape of the pattern.
  3. Read the explanation list for a token-by-token description.
  4. Enter a test string to see what matches and which groups capture what.
  5. Copy a ready-made snippet in your language.

Reading the railroad diagram

  • Rounded boxes are literal text; square boxes are character classes like digit or one of a–z.
  • A path that splits into parallel rails is an alternation (a|b).
  • A rail that loops back under a box means "repeat"; a rail that bypasses the box means "optional".
  • Dashed frames are groups; capture groups are numbered and named groups show their name.
  • Lookarounds are drawn as labeled frames because they check text without consuming it.

Tips

  • Prefer \d and character classes over long alternations for speed and clarity.
  • Lazy quantifiers (*?, +?) are shown with "as few as possible" in the explanation.
  • When porting patterns, remember that Go's RE2 engine does not support lookarounds or backreferences; the Go snippet warns you when your pattern uses them.
  • Escape backslashes in normal string literals, or use raw strings (r"..." in Python, backticks in Go) as the snippets do.

Frequently asked questions

Which regex flavor is used?

The parser and matcher use JavaScript (ECMAScript 2024) syntax, including named groups, lookbehind and Unicode property escapes with the u flag.

How is this different from the regex tester?

The regex tester focuses on matching and replacing text. The visualizer focuses on understanding and documenting a pattern.

Can I save the diagram?

The diagram is an SVG; right-click it to save or copy the image.

Does my pattern or text leave the browser?

No. Parsing, drawing and matching all happen locally.

Yes. All processing happens directly in your browser using JavaScript, Web Workers and Web APIs. Nothing you type, paste or upload is sent to our servers.