Toolgeist › Developer
Regex to NFA Visualizer — Thompson's Construction, Built From Scratch
This is a real regex engine, not a JavaScript RegExp call with a nicer UI. Your pattern is parsed into an AST and compiled into an actual NFA (nondeterministic finite automaton) using Thompson's construction — the textbook algorithm regex engines are built on — then matched against your test string character by character, with every currently-active NFA state visible via epsilon-closure at each step.
How to use Regex to NFA Visualizer
- Enter a pattern — literals, ., character classes, |, (), *, +, ? are all supported.
- Enter a test string.
- Watch the active NFA state set update after each character.
- Try a preset to see alternation, classes and repetition compile differently.
Frequently asked questions
- What is Thompson's construction?
- A method for compiling a regular expression directly into an NFA, piece by piece — a literal becomes a two-state fragment, alternation adds branching epsilon transitions, star/plus/optional add looping or bypass epsilon transitions — the same construction used to explain how regex engines work in computer science courses.
- What does "epsilon-closure" mean in the state trace?
- A real NFA can have multiple valid paths active simultaneously — epsilon-closure is the full set of states reachable via free (non-character-consuming) transitions after each real match, which is exactly what is displayed after every character.
- Why does the match fail as soon as the active set is empty?
- An empty active state set means no path through the NFA survived that character — since there is nothing left to continue from, the match is dead immediately rather than only being checked at the end.
- Does it support the same syntax as JavaScript RegExp?
- It supports a real, useful core subset — literals, ., character classes [a-z]/[^0-9], alternation, grouping, and */+/? — built from scratch for this visualizer, not the full RegExp feature set (no backreferences or lookaround).
Related Developer tools
Also searched for: regex to nfa converter online · thompson construction visualizer · how regex engines work demo
Browse all 738 free tools on Toolgeist →