All toolsRegex to NFA Converter

Developer tool

Regex to NFA Converter

Convert a regular expression into a nondeterministic finite automaton with Thompson's construction. See the epsilon-NFA diagram and transition table instantly.

Operators: concatenation ab, union a|b, star a*, plus a+, optional a?, groups (…). Escape a metacharacter with \.

Enter a regular expression to build its NFA with Thompson's construction.

About this tool

Turn a regular expression into an NFA

Thompson's construction is the first stage of a lexical analyzer generator. It reads a regular expression and mechanically builds a nondeterministic finite automaton (NFA): each literal becomes a two-state machine, and the operators union, concatenation, star, plus, and optional each combine smaller machines using epsilon (ε) moves. The result is an NFA with a single start state and a single accepting state that recognizes exactly the language of the expression.

This tool parses your expression, applies the construction, and draws the resulting NFA as both a state diagram and a transition table with the epsilon column shown explicitly. Because Thompson's NFA is deliberately verbose, it is the ideal starting point for the next stages: subset construction to remove nondeterminism, and Hopcroft's algorithm to minimize the machine.

How it works

Build an NFA in three steps

  1. 1Enter a regex

    Type a regular expression using concatenation, |, *, +, ?, and parentheses, or load the sample.

  2. 2Read the NFA

    See the epsilon-NFA as a diagram and a transition table with the start and accept states marked.

  3. 3Continue the pipeline

    Follow the pipeline bar to convert the NFA to a DFA and then minimize it.

Common questions

Thompson's construction FAQ

What is Thompson's construction?

Thompson's construction is an algorithm that builds a nondeterministic finite automaton (NFA) from a regular expression by translating each operator into a small sub-automaton and wiring them together with epsilon (ε) transitions. It always produces exactly one start state and one accept state.

What is an epsilon (ε) transition?

An epsilon transition lets the automaton move between states without consuming an input symbol. Thompson's construction uses them to glue the sub-automata for union, star, plus, and optional together, which is why the resulting NFA has so many states.

Which regular expression operators are supported?

Concatenation (ab), union (a|b), Kleene star (a*), one-or-more (a+), optional (a?), and grouping with parentheses. Escape a metacharacter with a backslash, for example \* to match a literal star. This is the classic formal-language model, not the extended syntax of programming regex engines.

How do I turn this NFA into a DFA?

Use the NFA to DFA converter linked in the pipeline bar to run subset construction, then the DFA minimizer for Hopcroft's algorithm. The full pipeline tool does all three stages from a single regular expression.

Is my expression uploaded anywhere?

No. Parsing and Thompson's construction run entirely in your browser. Nothing you type is sent to a server.