Brainfuck Language Reference

Brainfuck is an esoteric programming language with only 8 commands. It operates on a tape of memory cells, each initially set to zero, and a pointer that starts at the first cell.

Overview

A Brainfuck program manipulates a linear tape of cells using a movable pointer. Each cell holds a numeric value. The language has exactly 8 instructions — all other characters are treated as comments.

Commands

CommandDescription
>Move the pointer one cell to the right
<Move the pointer one cell to the left
+Increment the value at the current cell by 1
-Decrement the value at the current cell by 1
.Output the value at the current cell as an ASCII character
,Read one byte of input and store it in the current cell
[If the current cell is 0, jump forward to the matching ]
]If the current cell is not 0, jump back to the matching [

Using the Editor

ControlDescription
RunExecute the program at full speed (respects speed slider)
StepExecute a single instruction and pause
PausePause a running program
ResetStop execution and clear all state
Speed sliderControl execution speed (1 to 10,000 steps per frame)
Cell sizeChoose 8-bit, 16-bit, or 32-bit cells
Input modeToggle between pre-filled input buffer and interactive input
Save & ShareSave the program and get a shareable URL

Visit the Gallery to try example programs. Clicking "Try it" loads the program into the editor.

Debugger

The tape visualizer shows the memory tape with the current pointer highlighted. During step-through execution, the current instruction is highlighted in the source code.

Use Step to advance one instruction at a time, or Run with a slow speed to watch execution in real time. The tape display auto-scrolls to follow the pointer.

Cell Sizes

SizeRangeNotes
8-bit (default)0 – 255Classic Brainfuck. Most programs expect this.
16-bit0 – 65,535Larger range, useful for arithmetic-heavy programs.
32-bit0 – 4,294,967,295Maximum range. Overflow wraps around.

All cell sizes use wrapping arithmetic: incrementing past the maximum wraps to 0, and decrementing below 0 wraps to the maximum value.

Example Patterns

PatternDescription
[-]Clear cell: decrement until zero
[->+<]Move: copy cell 0 to cell 1 (destructive)
[->+>+<<]>>[-<<+>>]Copy: duplicate cell 0 to cell 1 (non-destructive)
,[.,]Cat: echo all input to output
+++++++++++++++++++++++++++++++++.Print '!' (ASCII 33 = 33 increments)

Primordial Soup Simulation

The simulation mode implements a primordial soup inspired by the “Computational Life” paper (arXiv:2406.19108). A population of 64-byte BFF programs live on a 2D toroidal grid (spatial mode) or interact randomly (well-mixed mode). Each epoch, programs are paired, concatenated, and executed on a shared 256-byte tape. The resulting tape is split back into two new programs that replace the parents.

How Interaction Works

When two programs A and B interact:

  1. The 256-byte tape is pre-loaded: bytes 0–63 from parent A, bytes 64–127 from parent B, bytes 128–255 remain zero.
  2. A’s 64 bytes followed by B’s 64 bytes are executed as a single 128-byte BFF program on the pre-loaded tape.
  3. Tape bytes 0–63 become the new A; bytes 64–127 become the new B.
  4. Each tape byte is mapped to a valid instruction via modular indexing into the instruction set.
  5. If mutation is enabled, random point mutations are applied to the offspring.

Tape pre-loading ensures the tape contains meaningful data before execution, preventing convergence to a trivial all-“>” monoculture.

BFF Instructions

BFF extends standard Brainfuck with a second read head for inter-program communication:

CommandDescription
> <Move head 1 right/left
{ }Move head 2 right/left
+ -Increment/decrement cell at head 1
[ ]Loop while cell at head 1 is non-zero
^Copy cell at head 2 to cell at head 1
vCopy cell at head 1 to cell at head 2

Configuration

SettingDescription
Grid Width/HeightDimensions of the 2D toroidal grid (population = width × height)
Step LimitMaximum BFF instructions per interaction (prevents infinite loops)
RadiusInteraction radius — how far a cell looks for neighbors
Instruction SetBFF (10 ops with dual heads) or Standard BF (8 ops)
Mutation RateExpected mutations per program per interaction (0 = off, try 0.1 for diversity)
Spatial GridWhen checked, programs interact with neighbors on a 2D grid. When unchecked, programs pair randomly (well-mixed mode).

Overlay Modes

ModeDescription
SpeciesColor-codes cells by program hash — same color = same species
ActivityGreen brightness = how many times a cell has changed
AgeBlue brightness = how long since a cell was last modified