Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

ruby2js

> 编程语言
Open source

Ruby to JavaScript conversion

491 stars0 likes0 views
WebsiteGitHub

About

Ruby to JavaScript conversion

Ruby2JS

Minimal yet extensible Ruby to JavaScript conversion. Documentation | Live Demo

Installation

ruby
# Gemfile
gem 'ruby2js'

Or install directly:

bash
gem install ruby2js

Examples

Ruby2JS converts Ruby syntax to clean, readable JavaScript:

ruby
# Ruby                              # JavaScript
a = { age: 3 }                      # let a = {age: 3}
a.age += 1                          # a.age++

items.map { |x| x * 2 }             # items.map(x => x * 2)

class Dog  let a = {age: 3}; a.age++

Command Line

bash
ruby2js --preset file.rb
echo "puts 'hello'" | ruby2js --preset

Features

  • Filters - Transform Ruby methods to JavaScript equivalents (e.g., .each → .forEach)
  • ES Level Support - Target specific JavaScript versions (ES2020 through ES2025)
  • Framework Integrations - Rails, Stimulus, React, Lit, and more
  • Live Demo - Try it in your browser (runs entirely client-side via Opal)

Demos

  • Opal Demo - Full-featured demo using Opal (~5MB)
  • Selfhost Demo - Lightweight demo using transpiled Ruby2JS (~200KB + Prism WASM)
  • Ruby2JS-on-Rails - Rails-like blog app running entirely in JavaScript

The selfhost demo runs Ruby2JS transpiled to JavaScript, demonstrating that Ruby2JS can convert itself. The Ruby2JS-on-Rails demo shows a complete Rails-style MVC application with ActiveRecord, controllers, and ERB views running in the browser or on Node.js/Bun/Deno.

Contributing

Running Tests

bash
bundle install
bundle exec rake test_all

Running the Website Locally

The ruby2js.com website (including the live demo) can be run locally from the docs folder:

bash
cd docs
bundle install
yarn install
bundle exec rake            # build demo assets (Opal-compiled ruby2js, etc.)
bin/bridgetown start        # run the site's dev server

The site will be available at http://localhost:4000.

Release Process for Maintainers

  1. Update the version in both packages/ruby2js/package.json and lib/ruby2js/version, ensuring they match.
  2. Run bundle exec rake release_core

License

MIT License - Copyright (c) 2009, 2025 Macario Ortega, Sam Ruby, Jared White

See LICENSE for details.

Issues· 26 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rubyjavascriptruby

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言