ruby/ruby.wasm

ruby.wasm is a collection of WebAssembly ports of the CRuby.

Ruby

876

1,609 commits

updated Oct 19, 2026

See the code

README

ruby.wasm

Build ruby.wasm

ruby.wasm is a collection of WebAssembly ports of CRuby. It enables running Ruby applications in browsers, WASI compatible WebAssembly runtimes, and Edge Computing platforms.

Try ruby.wasm (no installation needed)

Try ruby.wasm on TryRuby in your browser.

Quick Example: Ruby in a Web browser

Create and save an index.html page with the following contents:

<html>
  <script src="https://cdn.jsdelivr.net/npm/@ruby/[email protected]/dist/browser.script.iife.js"></script>
  <script type="text/ruby">
    require "js"

    puts RUBY_VERSION # (Printed to the Web browser console)
    JS.global[:document].write "Hello, world!"
  </script>
</html>

Quick Example: How to package your Ruby application as a WASI application

Dependencies: wasmtime

$ gem install ruby_wasm
# Download a prebuilt Ruby release
$ curl -LO https://github.com/ruby/ruby.wasm/releases/latest/download/ruby-4.0-wasm32-unknown-wasip1-full.tar.gz
$ tar xfz ruby-4.0-wasm32-unknown-wasip1-full.tar.gz

# Extract ruby binary not to pack itself
$ mv ruby-4.0-wasm32-unknown-wasip1-full/usr/local/bin/ruby ruby.wasm

# Put your app code
$ mkdir src
$ echo "puts 'Hello'" > src/my_app.rb

# Pack the whole directory under /usr and your app dir
$ rbwasm pack ruby.wasm --dir ./src::/src --dir ./ruby-4.0-wasm32-unknown-wasip1-full/usr::/usr -o my-ruby-app.wasm

# Run the packed scripts
$ wasmtime my-ruby-app.wasm /src/my_app.rb
Hello

npm packages (for JavaScript host environments)

See the README.md of each package for more detail and its usage.

PackageDescriptionnpm
@ruby/4.0-wasm-wasiCRuby 4.0 built on WASI with JS interop supportnpm version
@ruby/3.4-wasm-wasiCRuby 3.4 built on WASI with JS interop supportnpm version
@ruby/3.3-wasm-wasiCRuby 3.3 built on WASI with JS interop supportnpm version
@ruby/3.2-wasm-wasiCRuby 3.2 built on WASI with JS interop supportnpm version
@ruby/head-wasm-wasiHEAD CRuby built on WASI with JS interop supportnpm version
@ruby/head-wasm-emscriptenHEAD CRuby built on Emscripten (not well tested)npm version

Prebuilt binaries

This project distributes prebuilt Ruby binaries in GitHub Releases. A build is a combination of ruby version, profile, and target.

Supported Target Triples

TripleDescription
wasm32-unknown-wasip1Targeting WASI Preview1 compatible environments
(e.g. Node.js, browsers with polyfill, wasmtime, and so on)
wasm32-unknown-emscriptenTargeting JavaScript environments including Node.js and browsers

Profiles

ProfileDescription
minimalNo standard extension libraries (like json, yaml, or stringio)
fullAll standard extension libraries

Notable Limitations

The current WASI target build does not yet support Thread related APIs. Specifically, WASI does not yet have an API for creating and managing threads yet.

Also there is no support for networking. It is one of the goals of WASI to support networking in the future, but it is not yet implemented.

Contributing

See CONTRIBUTING.md for how to build and test, and how to contribute to this project. Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/ruby.wasm

emscripten
ruby
wasi
wasm
webassembly

ruby/ruby.wasm

ruby.wasm is a collection of WebAssembly ports of the CRuby.

Ruby

876

1,609 commits

updated Oct 19, 2026

See the code

README

ruby.wasm

Build ruby.wasm

ruby.wasm is a collection of WebAssembly ports of CRuby. It enables running Ruby applications in browsers, WASI compatible WebAssembly runtimes, and Edge Computing platforms.

Try ruby.wasm (no installation needed)

Try ruby.wasm on TryRuby in your browser.

Quick Example: Ruby in a Web browser

Create and save an index.html page with the following contents:

<html>
  <script src="https://cdn.jsdelivr.net/npm/@ruby/[email protected]/dist/browser.script.iife.js"></script>
  <script type="text/ruby">
    require "js"

    puts RUBY_VERSION # (Printed to the Web browser console)
    JS.global[:document].write "Hello, world!"
  </script>
</html>

Quick Example: How to package your Ruby application as a WASI application

Dependencies: wasmtime

$ gem install ruby_wasm
# Download a prebuilt Ruby release
$ curl -LO https://github.com/ruby/ruby.wasm/releases/latest/download/ruby-4.0-wasm32-unknown-wasip1-full.tar.gz
$ tar xfz ruby-4.0-wasm32-unknown-wasip1-full.tar.gz

# Extract ruby binary not to pack itself
$ mv ruby-4.0-wasm32-unknown-wasip1-full/usr/local/bin/ruby ruby.wasm

# Put your app code
$ mkdir src
$ echo "puts 'Hello'" > src/my_app.rb

# Pack the whole directory under /usr and your app dir
$ rbwasm pack ruby.wasm --dir ./src::/src --dir ./ruby-4.0-wasm32-unknown-wasip1-full/usr::/usr -o my-ruby-app.wasm

# Run the packed scripts
$ wasmtime my-ruby-app.wasm /src/my_app.rb
Hello

npm packages (for JavaScript host environments)

See the README.md of each package for more detail and its usage.

PackageDescriptionnpm
@ruby/4.0-wasm-wasiCRuby 4.0 built on WASI with JS interop supportnpm version
@ruby/3.4-wasm-wasiCRuby 3.4 built on WASI with JS interop supportnpm version
@ruby/3.3-wasm-wasiCRuby 3.3 built on WASI with JS interop supportnpm version
@ruby/3.2-wasm-wasiCRuby 3.2 built on WASI with JS interop supportnpm version
@ruby/head-wasm-wasiHEAD CRuby built on WASI with JS interop supportnpm version
@ruby/head-wasm-emscriptenHEAD CRuby built on Emscripten (not well tested)npm version

Prebuilt binaries

This project distributes prebuilt Ruby binaries in GitHub Releases. A build is a combination of ruby version, profile, and target.

Supported Target Triples

TripleDescription
wasm32-unknown-wasip1Targeting WASI Preview1 compatible environments
(e.g. Node.js, browsers with polyfill, wasmtime, and so on)
wasm32-unknown-emscriptenTargeting JavaScript environments including Node.js and browsers

Profiles

ProfileDescription
minimalNo standard extension libraries (like json, yaml, or stringio)
fullAll standard extension libraries

Notable Limitations

The current WASI target build does not yet support Thread related APIs. Specifically, WASI does not yet have an API for creating and managing threads yet.

Also there is no support for networking. It is one of the goals of WASI to support networking in the future, but it is not yet implemented.

Contributing

See CONTRIBUTING.md for how to build and test, and how to contribute to this project. Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/ruby.wasm

emscripten
ruby
wasi
wasm
webassembly

Significant stargazers

(top 24 of 34)

Andrew Kane

6,963 followers · starred Aug 2024

Linda_pp

1,943 followers · starred Dec 2021

Yosh

3,425 followers · starred Mar 2025

Adrian Cole

908 followers · starred Feb 2023