Regex to Automaton illustration

Regex to Automaton

Under the hood a regular expression is a finite automaton — a little machine with states and arrows. This visualizer takes classic regexes over the alphabet {a, b}, builds the automaton, and lets you feed it strings: the active states light up as each character is consumed, ending green if the string is accepted and red if not. Watching several states glow at once makes nondeterminism — the N in NFA — suddenly concrete.

Runs 100% in your browser — simulations are computed locally on your device.

Notes

  • Thompson’s construction turns any regex into an NFA with at most 2 states per regex symbol.
  • An NFA can be in several states at once; the subset construction turns it into a DFA.
  • Regular expressions, NFAs and DFAs all describe exactly the same languages — the regular languages.
  • Runs 100% in your browser — simulations are computed locally on your device.