Project Nayuki

Brainfuck interpreter (JavaScript)



This JavaScript program executes the given program written in the brainfuck programming language.

In the program code, characters other than the 8 brainfuck commands (<>+-[].,) are ignored. During execution, each memory cell is an unsigned 8-bit integer, and +/- wrap around on overflow. The memory stretches infinitely on the left and right sides; any integer is a valid memory index. The input is captured when the program is loaded, and cannot be changed afterward. Reading past the end of the input yields 0, which is indistinguishable from reading the byte value 0.

The source code is available for viewing.


Title Code Demo
Hello world
Echo the input
Reverse the input
Infinite loop
Binary counter
- [ >[->]+ +[-<+]- ]
Mandelbrot set mandelbrot.b by Erik Bosman
(takes 10 521 107 970 steps)

More info