An optimizing brainfuck interpreter in js
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Juhani Krekelä 06616ff8be Bump version number 4 years ago
.gitignore First commit 6 years ago
.npmignore Prepare for publishing to npm registry 6 years ago
CC0 Switch to CC0 license 4 years ago Fix typo in the example program 6 years ago Document the API 6 years ago Document the architecture of Gir 6 years ago Support all the types of EOF 6 years ago
gir.html Move Gir to use modules 6 years ago
gir.js Let's not accidentally be quadratic in : 4 years ago Document writeInt, readInt, breakPoint 6 years ago
ircbot.js Also replace DEL with its graphical equivalent 6 years ago Update documentation 6 years ago
package.json Bump version number 4 years ago

Gir is an optimizing brainfuck interpreter in Javascript.


𒌋𒀜 gir (Sumerian) - n. kiln


Everything in the repo is under Unlicense / CC0.


Gir can parse, prettyprint, and run programs in brainfuck. Gir supports following optimizations:

  • Turn runs of +- or <> into one command
  • Turn [-] or [+] into one command
  • Add offsets to commands that modify tape, to reduce moving tape head
  • Turn multiply loops into one command


ircbot.js is an implementation of an IRC bot's brainfuck interpreter function. Smaller examples for every function are available in

const gir = require('bf-gir');
let compiled = gir.compile(',[+.,]');
let input = gir.encodeUTF8('Foobar');
let vm = gir.newVM(compiled, input);
let result = gir.runVM(vm, 1000);

if(result.complete) {
} else {
	console.log('Bf program terminated abnormally');


Gir is available at npm registry under the name bf-gir.



  • Implement a UI


  • Move stuff into subdirectories?