Skip to main content

Regex Visualizer — Railroad Diagram + Character-Level Match

Regex visualizer — see your pattern as a railroad diagram + matching state machine, with capture groups highlighted.

  • Runs locally
  • Category Developer & DevOps
  • Best for Formatting, validating, shrinking, or inspecting code-adjacent text.
//gi
Flags
Railroad diagram
\b group #1 \w 1+ (one or more) · greedy @ group #2 \w 1+ (one or more) · greedy \. \w 1+ (one or more) · greedy \b
Character-level matchMatch count: 2
Email alice@toolora.info or bob@example.com to ping us.
matched captured
Sample library

Pattern and test string never leave your browser tab.

What this tool does

Free in-browser regex visualizer. Paste any JavaScript regular expression and you get three things at once: a railroad diagram (regexper.com-style flow chart with branches for alternation, loops for quantifiers, dashed boxes for every capture group, named group, lookahead and lookbehind), a character-level match view that paints each character of your test string in one of three colors so you can see at a glance which bytes matched and which sit inside which capture group, and a one-click sample library covering the ten patterns engineers actually paste most (email, URL, IPv4, Chinese 18-digit ID, Chinese mobile, ISO date, HTML tag, hex color, US ZIP, strong password). Under the hood it's a hand-written recursive-descent parser, no external runtime, total bundle well under 30 KB. The parser covers the full JS regex grammar — anchors (^ $ \b \B), character classes including negated, dot, all six escape categories, all four quantifier shapes with greedy/lazy modifier, alternation, capture / non-capture / named groups, positive and negative lookahead and lookbehind, numbered and named backreferences, \xNN, \uNNNN, and \u{NNNNN} escapes. When parsing fails, the error message points to the exact character offset with a highlighted caret so you see which token broke it — much more useful than the browser's "Invalid regular expression". A Download SVG button packages the diagram as a standalone .svg you can drop into Notion, Google Docs, or a PR review. 100% client-side, no API calls, no telemetry. Pairs with Regex Tester (match counts, replace preview) and Regex Cheatsheet (escape reference).

Tool details

Input
Files + Text + Numbers
The page exposes text boxes, numeric controls, file pickers, or structured inputs depending on the tool.
Output
Live result + Copy + Download
The result area focuses on usable output, with copy, download, or preview actions when supported.
Privacy
Browser-side processing
The main tool logic does not call an external API, so inputs normally stay in the current tab.
Save / share
Shareable URL state
Key settings are encoded in the URL so another person can reopen the same setup.
Performance budget
Initial JS <= 30 KB
No WASM budget is declared, keeping the tool quick to open on mobile.
Best fit
Developer & DevOps · Developer
Category and role tags drive related tools, internal links, and quick fit checks.

How to use

  1. 1. Input

    Paste or drop your content into the tool panel.

  2. 2. Process

    Click the button. All processing is local in your browser.

  3. 3. Copy / Download

    Copy the result or download to disk in one click.

How Regex Visualizer fits into your work

Use it in the small gaps between coding, reviewing, debugging, and shipping.

Developer jobs

  • Formatting, validating, shrinking, or inspecting code-adjacent text.
  • Preparing snippets for documentation, tickets, commits, or handoff.
  • Checking a small payload quickly without switching tools.

Developer checks

  • Run irreversible transforms like minify or obfuscate on a copy.
  • Keep secrets out of pasted snippets unless the tool explicitly stays local.
  • Use your normal tests or linter before shipping transformed code.

Good next steps

These links move the current task into a more complete workflow.

  1. 1 Vim Cheatsheet Vim cheat sheet — 100+ commands covering modes, motions, edits, search, registers, splits, with mnemonics. Open
  2. 2 Regex Tester Test JavaScript regex live — match highlighting, group capture, replace preview, flag toggles — browser-only Open
  3. 3 Regex Cheatsheet Interactive regex cheat sheet — quick reference for every flavor (JS, Python, PCRE). Open

Real-world use cases

  • Read a 200-character regex from a coworker's PR in 30 seconds

    Your coworker submits a PR with `^(?:[a-zA-Z0-9_'^&\/+-])+(?:\.(?:[a-zA-Z0-9_'^&\/+-])+)*@(?:[a-zA-Z0-9-])+(?:\.(?:[a-zA-Z0-9-])+)*$` and you're supposed to review whether it correctly validates emails. Paste it into the visualizer. The railroad diagram shows the structure in one screen — local-part with allowed chars, optional dot-separated sub-parts, @ sign, domain with allowed chars, optional dot sub-domains, end anchor. You now understand it in 30 seconds instead of squinting at the string for ten minutes. You can also test the diagram against edge-case strings (Unicode in the local part, IDN domains) by pasting them into the test string box.

  • Teach a junior dev what a capture group actually is

    You're pairing with a new hire who has heard of regex but never internalized capture groups. Open the visualizer, load the email sample, and point to the dashed amber boxes — those are the capture groups. Change the test string and watch the pink highlights move with the actual captured characters. The "abstract concept" becomes a thing they can see, and they stop confusing capture groups with character classes (a surprisingly common bug).

  • Embed a regex diagram in design docs

    Your design doc explains the routing layer's URL parser and someone is going to ask "what counts as a valid slug". Open the visualizer, paste your slug regex, click Download SVG, drop the .svg into the doc. The reader now has a visual spec, not just a wall of escapes. The SVG is self-contained so it survives doc exports to PDF and email forwards.

  • Debug why a regex isn't matching the string you expected

    You wrote `^https?:\/\/\w+\.com` to extract dot-com URLs and it's not catching `https://sub.toolora.com`. Paste both into the visualizer. The character-level view immediately shows that nothing in your test string is highlighted past `sub` — because `\w+` only consumed `sub` and then expected `.com` but got `.toolora`. The diagram makes it obvious: you need a dotted-subdomain group between the `//` and the `\.com`. Without the visualizer this is the kind of bug that eats an afternoon.

  • Generate teaching material for a regex workshop

    You're running an internal workshop on regex. Open each of the ten sample patterns one by one, screenshot the railroad diagram (or use Download SVG), and you have a slide deck. Each diagram shows structure rather than syntax, which is the gap most regex tutorials never bridge.

Common pitfalls

  • Double-escaping backslashes. When you copy `"\\d+"` from a JavaScript string literal, the `\\` is the source representation of a single backslash. Type it as `\d+` here — one backslash. The visualizer doesn't go through a string-literal parser, so the second `\` is literally a `\` character, which then makes the next escape illegal.

  • Forgetting that `[abc-]` includes the literal `-` because it's at the end. The character-class box label shows what's actually inside the brackets — if you wrote `[a-z-A-Z]` thinking it was two ranges, look at the box label and you'll see it's `a-z`, literal `-`, then `A-Z`. Move the dash to the start or escape it.

  • Confusing `(?:...)` and `(?=...)`. The first is a non-capture group (a structural grouping that doesn't make a capture slot). The second is a positive lookahead (a zero-width assertion). The visualizer labels each box with its actual semantic so you can tell at a glance which is which.

  • Expecting `\b` to mean "any whitespace". It does not. `\b` is a zero-width word boundary anchor (it asserts the position between a word and a non-word character without consuming any character). The pink diamond shape is a visual cue that anchors don't consume characters — if you want to match whitespace, use `\s`.

  • Writing patterns that match the empty string (`a*`, `()`, `(?:.*)?`). These cause the global match loop to spin in the same place. The visualizer's match count tries to avoid the infinite-loop trap but the diagram will show a quantifier whose minimum is 0 around something that can also match nothing — that's the warning sign.

Privacy

Everything is computed in your browser — the recursive-descent parser that turns the pattern into an AST, the layout engine that measures each node, the SVG renderer, and the character- level match classifier that paints the test string. The pattern you type, the test string, the rendered diagram, and the SVG you download — none of it is sent to any server, none of it is logged or analyzed. No analytics on the pattern text, no usage telemetry. You can open DevTools → Network and watch: nothing goes out as you type. Works fully offline once cached.

FAQ

Tool combos

Folks in your role tend to reach for these alongside this tool.

Made by Toolora · 100% client-side · Updated 2026-06-12