Turing machine simulator

[ Back to home page ]
This is a Turing machine simulator.
To use it:

  1. Load one of the example programs , or write your own in the Turing machine program area. See below for syntax .
  2. Enter something in the ‘Input’ area – this will be written on the tape initially as input to the machine. Click ‘Reset’ to initialise the machine.
  3. Click on ‘Run’ to start the Turing machine and run it until it halts (if ever).
    Click on ‘Pause’ to interrupt the Turing machine while it is running.
    Alternately, click ‘Step’ to run a single step of the Turing machine.
  4. Click ‘Reset’ to restore the Turing machine to its initial state so it can be run again.



Current state


Turing machine program


Run at full speed

Initial input:
Advanced options
Initial state:
Machine variant:


Changes will take effect when the machine is reset.
Load an example program

  • Palindrome detector
  • Binary addition
  • Binary multiplication
  • Binary to decimal conversion
  • Turing’s sequence machine
  • Parentheses checker
  • Reverse Polish Boolean calculator
  • Primality test
  • 4-state busy beaver
  • Universal Turing machine


Save to the cloud



  • Each line should contain one tuple of the form ‘<current state> <current symbol> <new symbol> <direction> <new state>‘.
  • You can use any number or word for <current state> and <new state>, eg. 10, a, state1. State labels are case-sensitive.
  • You can use any character for <current symbol> and <new symbol>, or ‘_‘ to represent blank (space). Symbols are case-sensitive.
  • <direction> should be ‘l‘, ‘r‘ or ‘*‘, denoting ‘move left’, ‘move right’ or ‘do not move’, respectively.
  • Anything after a ‘;‘ is a comment and is ignored.
  • The machine halts when it reaches any state starting with ‘halt‘, eg. halt, halt-accept.


  • *‘ can be used as a wildcard in <current symbol> or <current state> to match any character or state.
  • *‘ can be used in <new symbol> or <new state> to mean ‘no change’.
  • !‘ can be used at the end of a line to set a breakpoint, eg ‘1 a b r 2 !‘. The machine will automatically pause after executing this line.
  • You can specify the starting position for the head using ‘*‘ in the initial input.
Technical details


Previous version

The Turing machine simulator is written in Javascript/HTML, and uses jQuery . Saved machines are stored as Gists on GitHub . You can browse the code here on GitHub .
Source code for this simulator is available on GitHub . You are welcome to download, copy, or adapt the code to your own needs. If you are doing something interesting with it, I’d be happy to hear from you about it.
The previous version of the Turing machine simulator is still available here .
Please send any bug reports, feedback, suggestions, etc. to Anthony Morphett , awmorp @ gmail.com

— Anthony Morphett – awmorp @ gmail.com