Clingo compiled to WebAssembly

Usage no npm install needed!

<script type="module">
  import clingoWasm from '';


Clingo WebAssembly

npm version CDN Clingo version Lua version Emscripten version Build WASM

Clingo compiled to WebAssembly with Emscripten. Try it online at or

The API is not finalized and may change.

This repo combines work from two previous repos: and

Installation and Usage


npm install clingo-wasm or yarn add clingo-wasm.

const clingo = require("clingo-wasm");"a. b:- a.").then(console.log);

In the Browser

Load Clingo from the JSDelivr CDN.

<script src=""></script>

We expose an UMD bundle that runs Clingo in a separate worker thread. Therefore, all commands need to be asynchronous.

  async function main() {
    // optionally pass URL to WASM file:
    // await clingo.init("")
    console.log(await"a. b :- a."));
    console.log(await"{a; b; c}.", 0));



Build WASM file

Run yarn build:wasm if you have Docker. For testing purposes, you can run scripts/ from the root directory of the project.

Build and Test JavaScript

Run yarn build to build the js files. Run yarn test to run tests in node.

Update Lua, Clingo, or Emscripten

Update the versions in scripts/ and in the badges in this Then push to a new branch and let GitHub actions build the new WASM file.