Ruby Playground

Ruby code

Options

Choosing an example replaces code and input, and pauses Auto-run. Multiline code requires confirmation.

The first Run downloads the language runtime from jsDelivr. Ctrl/Cmd + Enter runs code. Monaco loads from a CDN only when enabled.

Plain editor

Interactive input waits for each answer in the console. Requires HTTPS and service workers; no backend and no persisted input.

0 lines · 0 chars

Monaco offers word suggestions (Ctrl + Space), plus JavaScript/TypeScript syntax and type diagnostics. Other languages have limited suggestions; check errors after Run. Suggestions need Monaco.

Console

You can type ahead. Enter sends a line when the program asks; EOF ends input. Answers are echoed in the console, not saved.

Timing measures elapsed time, not CPU time; waiting for input is included. WASM memory, when available, is linear memory capacity, not total RAM or peak usage.

Use STDIN.readline for terminal input. Runs in a Web Worker, without direct DOM access. Stop terminates execution; execution outside input waits is limited to 30 seconds, each answer can wait up to 2 minutes, and output is capped at 500 rows. Code can still make network requests, so only run code you trust. The tool does not save or upload your code or input.

Replace existing code?

Loading will replace the current code and input. Cancel to keep your work.

Runtime details

Interactive stdin installs a service worker scoped to /tools/ on its first Run. It answers only reserved input requests locally, without caching pages or persisting answers. If unavailable, use Prepared standard input. This is line-based input, not a shell or full terminal emulator.

The Ruby 3.4 WASI runtime (ruby.wasm 2.10.1) downloads from jsDelivr on Run. The binary is approximately 16 MiB before compression. Interactive terminal or prepared standard input; no gem installation or native OS processes. Runtime notices.

Learn

Ruby Playground Guide

About this tool

Run Ruby 3.4 in a disposable browser Worker using ruby.wasm 2.10.1 and a WASI adapter. The runtime downloads from jsDelivr only on Run or when Auto-run is enabled. Exercises cover arithmetic, logic, arrays, classes and pyramid patterns. Code and input are not saved or uploaded by the tool. Ruby’s JavaScript bridge can still access browser APIs and make requests; only run code you trust.

Questions

How do I read input?
Use STDIN.readline.chomp in Interactive terminal mode, then answer in the console with Enter. EOF (or Ctrl + D) ends the stream; readline can raise EOFError. Prepared standard input remains available for answers supplied before Run.
Why does the first Run take longer?
The Ruby WASM binary is approximately 16 MiB before compression. It downloads from jsDelivr and initializes in a fresh Worker. Runtime loading has a 90-second timeout, followed by a 30-second execution limit outside input waits. Each answer can wait up to 2 minutes. Normal HTTP caching can reuse assets between runs.
Can I install gems or run Rails?
This runner provides a browser WASI build, not a desktop Ruby installation or a web server. No gems are installed automatically; arbitrary native extensions and OS subprocesses are unavailable.
Does selecting an example erase my code?
Yes. Selecting immediately replaces code and standard input, and pauses Auto-run. If the editor contains more than one line, confirm deletion of existing code or cancel to keep code and input.
Is this a security sandbox?
No. A Worker prevents direct DOM access and can be terminated, but Ruby’s JavaScript bridge can make network requests. The tool itself does not upload or persist code or input. Each Run starts fresh; output is limited to 500 rows.