Brainfuck Interpreter
Execute Brainfuck programs in your browser — 30,000-cell tape, step debugger, visual memory display.
How to Use the Brainfuck Interpreter
- Enter your code — paste or type Brainfuck source code into the editor.
- Provide input — if your program uses the
,command, type input in the Input field. - Click Run — executes the program and shows output and the memory tape state.
- Use Step mode — click Step repeatedly to execute one instruction at a time, watching the tape update.
- 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
| Command | Effect |
|---|---|
> | 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.