Brainfuck Interpreter

Execute Brainfuck programs in your browser — 30,000-cell tape, step debugger, visual memory display.

Brainfuck Code
Input (for , commands)
Output
Memory Tape (first 32 cells)
Run a program to see memory.
Enter Brainfuck code and click Run.

How to Use the Brainfuck Interpreter

  1. Enter your code — paste or type Brainfuck source code into the editor.
  2. Provide input — if your program uses the , command, type input in the Input field.
  3. Click Run — executes the program and shows output and the memory tape state.
  4. Use Step mode — click Step repeatedly to execute one instruction at a time, watching the tape update.
  5. Try Examples — load pre-built programs like Hello World to learn the language.

About Brainfuck

Brainfuck is an esoteric programming language (esolang) invented by Urban Müller in 1993. Despite having only 8 commands, it is Turing-complete, meaning any computable function can be implemented in it. The language operates on an array of memory cells (the "tape") and a data pointer that moves along the tape. Its extreme minimalism makes it a favorite puzzle language for programmers who enjoy solving problems under severe constraints.

The 8 Commands

CommandEffect
>Move the data pointer one cell to the right
<Move the data pointer one cell to the left
+Increment the current cell by 1 (wraps 255→0)
-Decrement the current cell by 1 (wraps 0→255)
.Output the current cell value as ASCII character
,Read one byte of input into the current cell
[Jump past matching ] if current cell is 0
]Jump back to matching [ if current cell is nonzero

Memory Model

This interpreter uses a 30,000-cell tape as specified in the original Brainfuck specification. Each cell holds an unsigned 8-bit value (0 to 255). All cells are initialized to 0 at the start. Arithmetic operations wrap around: incrementing 255 gives 0, decrementing 0 gives 255. The data pointer starts at cell index 0. Moving the pointer left from cell 0 or right from cell 29999 results in an error.

Understanding Loops

The [ and ] commands form loops. When execution reaches [, it checks whether the current cell is zero. If zero, execution jumps to the instruction after the matching ]. If nonzero, execution continues normally. When execution reaches ], if the current cell is nonzero, it jumps back to the matching [. This simple mechanism allows implementing all standard loop patterns: while loops, for loops, and conditional branches. A common idiom is [-] which decrements the current cell until it reaches zero — a fast way to zero out a cell.

Hello World Explained

The classic Hello World program in Brainfuck is one of the most studied programs in the language. It works by using nested loops to efficiently build up ASCII values. The outer loop runs 8 times, and inner loops multiply values to reach character codes like 72 (H), 101 (e), 108 (l), 111 (o), and so on. Understanding this program teaches the fundamentals of Brainfuck arithmetic: since you can only increment and decrement by 1, multiplication is done via loops.

Safety Limits

This interpreter enforces a 10 million instruction limit to prevent infinite loops from freezing your browser. If your program exceeds this limit, execution halts and the current output and memory state are displayed. Step mode is useful for debugging — click Step to execute one instruction at a time, watching how the data pointer moves and cells change value. This makes it easy to understand how complex programs manipulate memory.

Frequently Asked Questions

Brainfuck is an esoteric programming language created by Urban Müller in 1993. It has only 8 commands: +, -, <, >, ., ,, [, and ]. Despite its minimal instruction set, Brainfuck is Turing-complete and is used primarily for entertainment, educational challenges, and code golf.
The 8 commands are: > (move pointer right), < (move pointer left), + (increment cell), - (decrement cell), . (output as ASCII), , (read input), [ (jump forward if cell is 0), and ] (jump back if cell is nonzero).
The most common cause is no dot (.) command in the program. Also check that your loop brackets are balanced. Use Step mode to trace execution and find where it gets stuck.
This interpreter provides 30,000 cells, each an 8-bit unsigned value (0–255). Arithmetic wraps around at both ends. The data pointer starts at cell 0.
Type your input string in the Input field. When the program executes a comma (,) command, it reads the next character as an ASCII byte. If input is exhausted, the cell is set to 0.