Online Ruby Compiler
Run Ruby 3.4 with the standard library, gets and STDIN. It is CRuby compiled to WebAssembly, so your code never leaves the page.
Start from an example
main.rb
Standard input (stdin)
Output
Nothing has run yet
Press Run to see what the program prints, or load one of these:
CRuby 3.4, running in this tab
This is ruby.wasm, the official build of CRuby 3.4 for WebAssembly, with the standard library bundled in. puts, p, gets and STDIN.read work against the boxes on this page, and error messages read the way ruby prints them in a terminal.
The catch is size. The first run downloads about 29 MB (around 9 MB compressed). After that the interpreter stays loaded, and later runs start in about a tenth of a second.
- Version
- Ruby 3.4.1
- Platform
- wasm32-wasi
- Input
- gets, STDIN.read
- Gems
- None
- Run limit
- 10 seconds
- First load
- About 29 MB, then cached
What works and what does not
We ran every row of this table in the compiler before writing it down.
| Feature | Works? | Details |
|---|---|---|
| puts, print, p, pp Output is written as it happens, so you still see it if the run is stopped. | Yes | Output is written as it happens, so you still see it if the run is stopped. |
| gets, STDIN.read, $stdin All three read the stdin box. gets returns nil once it runs out. | Yes | All three read the stdin box. gets returns nil once it runs out. |
| Standard library json, set, date, time, prime, matrix, csv, yaml, digest, securerandom, stringio, benchmark and more. | Yes | json, set, date, time, prime, matrix, csv, yaml, digest, securerandom, stringio, benchmark and more. |
| Fibers and Enumerators Generators built on Fiber.yield or an Enumerator run normally. | Yes | Generators built on Fiber.yield or an Enumerator run normally. |
| sleep It really waits, so it counts toward the 10-second limit. | Yes | It really waits, so it counts toward the 10-second limit. |
| File.write and File.read They work during a run. Each run starts with an empty file system. | Partly | They work during a run. Each run starts with an empty file system. |
| Thread.new Raises NotImplementedError. This build has no threads. | No | Raises NotImplementedError. This build has no threads. |
| bigdecimal Not included in this WebAssembly build. | No | Not included in this WebAssembly build. |
| Gems (Nokogiri, Rails, RSpec) Nothing can be installed, so require raises LoadError. | No | Nothing can be installed, so require raises LoadError. |
| Net::HTTP and sockets The socket library is missing, and the sandbox blocks the network. | No | The socket library is missing, and the sandbox blocks the network. |
Why run Ruby here
A new VM for every run
Constants, globals and monkey patches from the last run are gone. Only the compiled interpreter is kept, which is why runs stay quick.
Error messages you recognize
Backtraces are trimmed to main.rb lines, and syntax errors show the Ruby 3.4 caret diagram pointing at the problem.
Fibers work
Threads are not available, but Fiber-based generators and lazy Enumerators run fine.
Stop works mid-loop
loop { } does not hang the page. Press Stop or wait 10 seconds, and the interpreter is shut down and restarted.
Errors you will probably hit
The first one trips up almost everyone who reads input.
undefined method 'chomp' for nil (NoMethodError)
What it meansgets returned nil because the stdin box ran out of lines.
FixAdd the missing input, or write gets.to_s.chomp so the end of input becomes an empty string.
cannot load such file -- nokogiri (LoadError)
What it meansGems are not installed here.
FixStick to the standard library, or run the script locally with bundle exec.
initialize() function is unimplemented on this machine (NotImplementedError)
What it meansThread.new was called, and this build has no threads.
FixDo the work in order, or use a Fiber.
stack level too deep (SystemStackError)
What it meansThe recursion went deeper than the WebAssembly stack allows.
FixRewrite it as a loop, or cache results in a Hash so fewer calls are needed.
syntax errors found (SyntaxError)
What it meansRuby could not parse the file. The caret lines under the message show where.
FixFix the marked spot. A missing end or a dangling operator is the usual cause.
How this Online Ruby Compiler works
When you press Run, the page passes your code and stdin to a sandboxed frame that cannot see this site, your cookies or the network. Inside it, a Web Worker runs ruby.wasm, which is CRuby 3.4 compiled to WebAssembly.
The first run downloads about 29 MB, which your browser caches. The compiled interpreter is kept between runs, but each run gets a brand-new VM and an empty file system, so nothing carries over.
How to use this Online Ruby Compiler
Write your code
Start from the sample, pick an example above the editor, or paste your own script.
Add stdin
One value per line. Each gets call takes the next line.
Run it
Press Run Ruby or Ctrl+Enter. The first run downloads the interpreter, then the output appears on the right.
Example Usage
With 3 4 5 in stdin, this adds up the numbers on the first line.
Frequently Asked Questions
Which Ruby version is this?
Why is gets returning nil?
Can I install gems?
Why is the first run slow?
Is my Ruby code sent to a server?
Can I use threads?
Related Tools
Online Code Formatter
Universal code beautifier for Python, Java, Swift, JavaScript, C#, HTML, and CSS. Clean up messy code instantly.
Online Syntax Highlighter
Highlight your code with syntax coloring for various languages. Generate HTML with inline styles or classes.
Source Code Viewer
View and analyze source code with syntax highlighting. Supports HTML, CSS, JavaScript, and more.
Regex Tester
Test and debug regular expressions with real-time match highlighting.
JavaScript Compiler
Write and run JavaScript online with stdin input, exit codes and instant output. It runs in a sandbox in your browser, so your code is never uploaded.
Python Compiler
Run Python 3 online with the full standard library and stdin input. It uses Pyodide (WebAssembly) in a browser sandbox, so your code is never uploaded.
Comments
Comments are provided by Disqus, which sets cookies and processes data under its own privacy policy.
The Online Ruby Compiler is maintained by CodeItBro. We aim to provide the best free developer tools on the web. If you have feedback or suggestions, please visit our contact page.

