Google Sheets · Ruby · WebAssembly

Ruby, in your sheet.

sheetruby brings Ruby to Google Sheets as a custom function. Write Ruby in a formula, pass in cells or ranges, and get the result back in your spreadsheet.

Ruby playground
fx =EVAL_RUBY_SCRIPT("$arg1 * 2", A2)
Powered by mruby/edge Apps Script

A Ruby VM in your spreadsheet.

sheetruby embeds mruby/edge into Google Apps Script as WebAssembly. No separate application server is needed: formulas are compiled and evaluated in the Apps Script environment.

01 / FORMULA

Feels native to Sheets

Call EVAL_RUBY_SCRIPT() like any other custom function and reference spreadsheet cells directly.

02 / RUBY

Real Ruby expressions

Use Ruby syntax and the bundled Math module for calculations, transformations, and text handling.

03 / TYPES

Values cross the bridge

Numbers, strings, booleans, and 2D cell-range arrays move between Sheets and Ruby through JSON serialization.

From formula to result.

The source text and spreadsheet values stay together through a compact Rust and WebAssembly pipeline.

Step 01

Sheets calls Ruby

The custom function receives Ruby source plus as many as three cell or range arguments.

Step 02

mruby/edge runs it

The embedded compiler produces mruby bytecode, then the Rust-based VM executes it inside Wasm.

Step 03

The value returns

The Ruby result is serialized as JSON and converted back into a value Google Sheets understands.

Get started

Paste once. Write Ruby anywhere.

  1. Open Apps ScriptIn your spreadsheet, choose Extensions → Apps Script.
  2. Install sheetrubyCopy the current combined.js into the editor and save.
  3. Use the functionReturn to the sheet and enter EVAL_RUBY_SCRIPT() in a cell.
Google Sheets formulas v0.2.0
# Evaluate Ruby directly
=EVAL_RUBY_SCRIPT("1 + 2")
→ 3

# Pass a cell as $arg1
=EVAL_RUBY_SCRIPT("$arg1 * 2", A1)
→ 42

# Ruby string methods
=EVAL_RUBY_SCRIPT("$arg1.upcase", A1)
→ "HELLO"

# Bundled Math support
=EVAL_RUBY_SCRIPT("Math.sqrt($arg1)", 16)
→ 4.0
Function signature

EVAL_RUBY_SCRIPT(code, arg1, arg2, arg3)

Cell ranges

Multiple cells arrive in Ruby as a two-dimensional array.

Argument limit

Up to three values or ranges are exposed as $arg1$arg3.

Open source · MIT licensed

Make your cells speak Ruby.

Explore the source, report an issue, or help shape the next version of sheetruby.