Unfuck

Brainfuck Examples

Simple Examples

Counter

Outputs the digit '5' (ASCII 53).

Code:
+++++++++++++++++++++++++++++++++++++++++++++++++++++.

Output: 5

Echo

Reads one character and outputs it.

Code:
,.

Input: Any visible character

Output: Same character

Move Value

Moves a value from one cell to another. Input two visible characters, outputs their sum as a character. For example, input '1' and '2' (ASCII 49 and 50) will output 'c' (ASCII 99).

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

Input: Two visible characters (e.g., 1 and 2)

Output: Sum as visible character (e.g., 'c')

Intermediate Examples

Hello World

The classic 'Hello World!' program.

Code:
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.

Output: Hello World!

Multiplication

Multiplies two single-digit numbers. Input two digits (e.g., '3' and '4'), outputs their product as a character (e.g., 'L' for 3*4=12+48=60, ASCII 60 is '<').

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

Input: Two digits (e.g., 3 and 4)

Output: Product as visible character (e.g., '<')

Advanced Examples

Truth Machine

If input is '0', outputs '0'. If input is '1', outputs infinite '1's. (Input must be the digit '0' or '1')

Code:
,[.[-]+,]

Input: 0 or 1 (as digit)

Output: 0 or infinite 1s

Cell Copy

Copies a value to multiple cells. Input a visible character, result is value copied to next cell.

Code:
,[>+>+<<-]>>[<<+>>-]<<

Input: One visible character (e.g., 'A')

Output: Value copied to next cell

How to Use These Examples

  1. Click "Copy" to copy the code to your clipboard
  2. Click "Try it out" to load the example directly into the interpreter
  3. Add any required input in the input field
  4. Click "Run" to execute or "Step" to step through
  5. Try modifying the code to see what happens!