← Back to Software

Brainfuck Documentation

The minimalist esoteric programming language

Introduction

Brainfuck is an esoteric programming language created in 1993 by Urban Müller. It consists of only eight simple commands and operates on an array of memory cells, each initially set to zero.

Note: Brainfuck is designed to be minimalist and challenging to use. It's primarily used for educational purposes and programming challenges.

Commands

Brainfuck has exactly 8 commands:

Command Description
> Move the data pointer to the right
< Move the data pointer to the left
+ Increment the byte at the data pointer
- Decrement the byte at the data pointer
. Output the byte at the data pointer as ASCII character
, Input a byte and store it at the data pointer
[ Jump forward to the matching ] if the byte at data pointer is zero
] Jump back to the matching [ if the byte at data pointer is non-zero

Hello World

The classic "Hello World" program in Brainfuck:

++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.

This outputs: Hello World!

Simple Examples

Print 'A' (ASCII 65)

++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.

Add two single digits

,>++++++[<-------->-]<[>+<-]>++++++[<++++++++>-]<.

Infinite loop

+[]

Clear current cell

[-]

Memory Model

Brainfuck operates on:

  • Memory array: An array of at least 30,000 byte cells
  • Data pointer: Points to the current memory cell
  • Instruction pointer: Points to the current command
  • Input/Output: Character-based I/O streams

Programming Tips

  • Use loops
    [-]
    to clear cells
  • Use
    [>+<-]
    to move values between cells
  • Plan your memory layout before coding
  • Comment your code extensively (comments are any character not in the 8 commands)
  • Test small segments before building larger programs

Online Interpreters

Try Brainfuck online with these interpreters:

  • Copy.sh Brainfuck Interpreter
  • Brainfuck Visualizer
  • TIO (Try It Online)