dewasm converts WebAssembly binaries into pure source code for languages like Ruby, Bash, and Go.
No WebAssembly runtime is required.
The output runs anywhere plain ruby, bash, or go does.
Here is cowsay, a WebAssembly binary, converted to a pure Bash script and run with nothing but bash:
$ dewasm examples/apps/cache/cowsay.wasm --target bash --mode standalone -o cowsay.sh
$ echo "Hello from Bash" | bash cowsay.sh
_________________
< Hello from Bash >
-----------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||Even QuickJS-NG, a JavaScript engine written in C, can be converted, this time to pure Ruby:
$ dewasm examples/apps/cache/qjs.wasm --target ruby --mode standalone -o qjs.rb
$ ruby qjs.rb -e 'console.log("2**16 =", 2**16); console.log(JSON.stringify(["Ruby", "JavaScript"].sort()))'
2**16 = 65536
["JavaScript","Ruby"]A WebAssembly binary can also be used as a library instead of a standalone application.
Here, a small example add.wat is converted and its add export is called directly from Ruby:
$ dewasm examples/wat/add.wat --target ruby --mode library --module-name Add -o add.rbrequire_relative "add"
inst = Add.new
inst.invoke("add", 2, 3) # => 5Beyond simple examples, dewasm scales to real libraries and applications too:
examples/railsruns a Rails blog on Ruby alone. The C extensions ofsqlite3,nokogiri,herb, andbcryptare converted to Ruby bydewasm.examples/doomports the WebAssembly version of DOOM to multiple languages, including Bash.examples/nesconverts a NES emulator (agnes) once. It turns every backend language into a native NES player.
Here is a quick summary of what dewasm can do:
- Support real-world binaries: Implements most of the Wasm 1.0 and WASI Preview 1 specifications. It also implements the exception-handling proposal on most backends.
- Target multiple languages: Translates one WebAssembly binary to Ruby, Bash, Go, and other languages.
- Adapt to your needs: Generates either standalone scripts or importable library source code.
- Keep it minimal: Bundles only the runtime code that the WebAssembly binary requires.
$ cargo install dewasmor:
$ git clone https://github.com/dewasm/dewasm && cd dewasm
$ cargo build --release$ dewasm input.<wasm|wat>
--target <ruby|bash|python|perl|go|java|codon>
--mode <standalone|library>
-o output.<rb|sh|py|pl|go|java|codon>inputis a WebAssembly binary to be translated.dewasmaccepts a WebAssembly text (WAT) file too.
--target(or-t) selects the target language (required).--mode(or-m) specifies the translation mode (default:library).--mode standaloneconnects WASI and runs the module's_start.--mode libraryexposes the module's exports to the target language.
--output(or-o) sets the output file (default:-).- When
-is specified,dewasmoutputs the result tostdout.
- When
--module-namenames the generated class/package, and is required in library mode.- Standalone output has a fixed internal name and rejects it.
Please see dewasm --help for the full list of options.
Next:
The MIT license. See the LICENSE file.
Copyright (c) 2026 Hiroya Fujinami