ToolSphere

Finite Automata Simulator (NFA/DFA)

Computer science

Draw an NFA or DFA, trace any input step by step and get its transition table. Share a link or export LaTeX TikZ and PNG. Free, no sign-up.

DFA and NFA simulator

Draw a machine or describe the language in words, then test a string. A DFA has exactly one arrow per symbol from each state; an NFA can have several, or ε (empty) moves.

Current DFA: 4 states, 7 transitions.

Drag a state to move it. Click a state to make it start or accepting, rename or delete it.

abababa,bq0q1q2q3

Test a string

Accepted by the current DFA. Press trace to inspect each move below.

Transition table (δ)

Stateab
→ q0{q1}{q3}
q1{q1}{q2}
*q2{q1}{q2}
q3{q3}{q3}

Each row shows where a state goes on each symbol. → marks the start state, * an accepting state.

On this browser only

Give feedback

Did this tool help?

Tell us what worked, what didn’t, or what you’d like next.

Opens Google Forms in a new tab with this tool’s name filled in. No sign-in or email required. Feedback is optional.

Coming from JFLAP? See what carries over and what JFLAP still does better →

Try next

How to use Finite Automata Simulator (NFA/DFA)

  1. 1Or skip drawing: type the question, such as "strings over {a,b} ending with ab" or "binary numbers divisible by 3", into Type the question and press Build DFA to get its minimal DFA.
  2. 2Load one of the eight example automata, or pick 'Add State' and click the canvas to place states; drag them (mouse or finger) to tidy the layout.
  3. 3Pick 'Add Transition', click the state it leaves from, then the state it goes to, and type the symbols (a,b for two, ε for an epsilon move).
  4. 4Select a state to make it the start state, an accept state, rename it or delete it.
  5. 5Type an input string and press Trace; step through or play the run to see which states are active after each symbol.
  6. 6Read the transition (δ) table beside the canvas, then use Share link, Copy LaTeX (TikZ) or Save PNG for your notes or assignment.

About Finite Automata Simulator (NFA/DFA)

A finite automaton maker that shows its work

Draw the automaton the way you would on paper: circles for states, arrows for transitions, a double circle for accepting states and an arrow into the start state. Then type an input and trace it. For a DFA the simulator lights up the single current state after every symbol; for an NFA it lights up the whole set of states the machine could be in, which is the part that is hard to keep straight by hand. Beside the canvas, the transition table (δ table) updates as you draw, in the layout exam answers use: one row per state, one column per symbol, → for the start state and * for accepting states.

DFA or NFA: which mode to use

A DFA has exactly one transition for every state and symbol, so a run is a single path and the answer is decided by the state you finish in. An NFA may have several transitions on the same symbol, none at all, or ε-moves that change state without reading input. It accepts if any of its possible runs ends in an accepting state. Every NFA has an equivalent DFA, but the DFA can need up to 2ⁿ states for an n-state NFA, which is why NFAs are the easier ones to design.

Switch to NFA mode whenever your diagram has a choice on some symbol or an ε arrow. In NFA mode the simulator takes the ε-closure at the start and after every symbol, so states reachable by ε-moves count as active too.

Worked example: strings ending in "abb"

Load the preset NFA: ends in 'abb'. It is the textbook four-state NFA over {a, b}: q0 loops on a and b, q0 –a→ q1, q1 –b→ q2, q2 –b→ q3, and q3 accepts. Trace babb:

After reading Active states
(start) {q0}
b {q0}
a {q0, q1}
b {q0, q2}
b {q0, q3} → accepted, q3 is accepting

Now trace abba: the active sets are {q0, q1}, {q0, q2}, {q0, q3}, then {q0, q1} after the final a. No accepting state is left, so it is rejected. The NFA "guesses" where the final abb begins by keeping q0 alive the whole time, while q1 → q3 checks the guess.

Those four active sets are exactly the states of the equivalent DFA. Open the NFA to DFA converter to see the subset construction build them one row at a time.

Examples you can load

Each example loads with a string it accepts, ready to trace. Every one has been checked against its language on all strings up to eight symbols long.

Example Type How it works
Starts with a, ends with b DFA, 4 states A trap state catches anything starting with b; two states remember whether the last symbol was b.
Ends in abb NFA, 4 states The start state loops on a and b, and guesses where the final abb begins.
NFA with ε NFA, 3 states Accepts exactly "a" and "b": an ε-move lets the start state also act as q1.
Even number of 0s DFA, 2 states One state for "even so far", one for "odd"; 0 switches between them, 1 stays put.
Binary multiple of 3 DFA, 3 states The state is the value read so far, mod 3. Reading bit b moves remainder r to (2r + b) mod 3, so "110" (six) goes r0 → r1 → r0 → r0.
Contains 101 DFA, 4 states The states track how much of 101 has just been seen; after a full match, an accepting state loops on everything.
Even a's and even b's DFA, 4 states One state per pair of parities (EE, OE, EO, OO); a flips the first, b the second.
3rd symbol from the end is 1 NFA, 4 states The NFA guesses which 1 is third from the end. A DFA for the same language needs 8 states, one for each pattern of the last three symbols.

The last one is the standard example of why NFAs matter: run it through the NFA to DFA converter and the subset construction produces all 8 states, none of which can be merged.

Share it, export it, hand it in

  • Share link puts the whole automaton, and the input you were tracing, into the URL. Anyone who opens it sees the same diagram ready to run, which is handy for checking an answer with a classmate or a teacher.
  • Copy LaTeX (TikZ) gives a tikzpicture using the standard automata library, with start and accepting states marked and loops and two-way edges laid out. Paste it into Overleaf for a lab report or thesis.
  • Save PNG downloads the diagram as an image for slides or a document.

Nothing is uploaded: the automaton lives in your browser and in the link itself.

The rest of the automata toolkit

The same notation carries across every theory-of-computation step:

For the theory behind them, read NFA vs DFA and the subset construction explained. Coming from JFLAP? See how these tools compare with JFLAP, or every tool for the course in the CS theory lab.

Guides and tutorials

Frequently asked questions

Can it make a DFA or NFA from the question?

Yes. Type the language as an exam question words it, for example "even number of 0s and does not contain 11", and press Build DFA. It reads starts with, ends with, contains, does not contain, counts, parity, length, binary or decimal divisibility and k-th symbol conditions joined by and/or, builds the exact minimal DFA, and says how it read each part. For ends with, contains and k-th from the end it can also show the small NFA. Wording it cannot read is reported, never guessed.

How do I make an NFA online?

Choose NFA mode, add states by clicking the canvas, then draw transitions by dragging from one state to another and typing their symbols. Several transitions on the same symbol, or an ε label, are allowed in NFA mode. Mark one start state and at least one accept state, type an input and press Trace.

How do I type an epsilon (ε) transition?

Label the transition ε. The simulator follows ε-moves automatically in NFA mode: it takes the ε-closure of the start state and of every set it reaches, so states you can get to without reading input are shown as active.

When does an NFA accept a string?

When at least one of its possible runs ends in an accepting state after the whole input has been read. In the trace that means the final active set contains an accepting state, even if other active states are not accepting.

Can it convert an NFA to a DFA?

Yes, in the NFA to DFA converter, which runs the subset construction and shows each new DFA state as the set of NFA states it stands for. You can then minimize the result in the DFA minimizer.

How do I get my automaton into LaTeX or Overleaf?

Press Copy LaTeX (TikZ). It copies a tikzpicture that uses the automata library, with initial and accepting states marked. Add \usetikzlibrary{automata, positioning, arrows.meta} to your preamble and paste it into the document.

How do I share an automaton with a classmate or teacher?

Press Share link. The automaton and your test input are packed into the URL and copied to the clipboard; opening the link restores exactly the same diagram, ready to trace. No account is needed and nothing is stored on a server.

What does the transition table show?

The δ function in table form: one row per state, one column per input symbol (plus ε when your NFA uses it), and in each cell the set of states that symbol leads to, or ∅ when there is none. → marks the start state and * marks accepting states.

How do I make a DFA for binary numbers divisible by 3?

Use three states for the remainder so far (0, 1 or 2), start and accept in remainder 0, and on bit b go from remainder r to (2r + b) mod 3. Load the 'binary multiple of 3' example to see it and trace any binary string.

What is the DFA for an even number of 0s?

Two states: 'even' (the start state, accepting) and 'odd'. Reading 0 switches between them and reading 1 stays in the same state. It is one of the eight examples you can load.

Is this a JFLAP alternative?

For finite automata, yes: it draws and traces DFAs and NFAs, converts NFA to DFA, minimizes DFAs and builds NFAs from regular expressions, and the PDA and Turing machine simulators cover the rest. It runs in the browser, so there is nothing to install and no Java needed.

Have a suggestion for Finite Automata Simulator (NFA/DFA)?Share your feedback ↗