Skip to content
A Javascript to PICO-8 Lua transpiler
JavaScript Lua
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.


jspicl is a Javascript to PICO-8 Lua transpiler. It creates an AST out of the JavaScript code and then transpiles it down to the LUA subset of which PICO-8 supports.

npm version library size npm downloads


Consider using jspicl-cli instead to simplify your project setup. It includes several additional features such as watch mode (reloading your game when code changes), using PNGs as your game's spritesheet etc.


npm install jspicl --save


import jspicl from "jspicl";

const javascriptCode = `...`;
const { output, polyfills } = jspicl(javascriptCode);

By default, jspicl formats the LUA output for you but if performance ever becomes an issue you can turn this off through the options argument.

const { output, polyfills } = jspicl(javascriptCode, { prettify: false });


Property Type Description
input string JavaScript code to transpile into PICO-8 LUA
options object
    prettify boolean Format output
    customMappers HashMap<string, function> Custom handlers for transpiling expressions, declarations or statements.

Return value

Property Type Description
output string The transpiled javascript code
polyfills object Table of required polyfills with their corresponding lua code.

Customized transpilation

jspicl does not support all expressions or statements out of the box but it is extensible enough to allow for these to be added. It also allows existing ones to be replaced if the implementation is considered unsatisfactory. This is done by supplying a customMappers option. The only requirement imposed on the AST node is that it contains a string property called type since this is used to identify the appropriate declaration, expression or statement.

const customMappers = {
  // Replace the default while-statement implementation
  WhileStatement: ({ body, test }, { transpile }) =>
    `while ${transpile(test)} do
      -- We have full control of the output!

  // Add support for missing features
  ForOfStatement: ({ left, right, body }) => {

  // Custom statements, declarations and expressions are also valid
  // as long as they are included in the AST
  SuperDuperComment: () =>
    `-- You're doing great!`

  // ...

const { output } = jspicl(javascriptCode, { customMappers });

Known limitations

ES2015+ Not all ES2015+ features are supported. Run your code through a transpiler first such as bublé or babel.
prototype chains Not supported
Array methods Not all prototype methods have been polyfilled yet.
Math.max Only supports two arguments.
AST Not all declarations, expressions and statements have been implemented. More will be added as needed.


This project uses semantic versioning

Related projects

jspicl CLI - Command line interface for jspicl

games - Games created with jspicl

You can’t perform that action at this time.