About this Ruby playground
This is a Ruby compiler you can use straight away. Write Ruby in the editor, press Run, and the output appears next to it: everything your program puts or prints, any error with its backtrace, and how long it took.
Your code runs on Ruby 3.0, the standard interpreter, in an isolated sandbox on our servers, so it behaves as it would with ruby main.rb on your own machine. It is free, with nothing to install and no account needed.
What you can run
- Ruby 3.0, running one file per run, saved as
main.rb. - Standard library only. The core classes (String, Array, Hash, Range, Struct and the Enumerable methods) and the standard library that ships with Ruby, loaded with require: json, set, date, time, securerandom, prime, bigdecimal and the rest. There is no package installer, and programs have no network access.
- Limits: 10 seconds and 256 MB of memory per run. Output past 64 KB is cut off, code can be up to 64 KB and input up to 16 KB.
- Fair use: 5 runs a minute and 50 a day without an account, 10 a minute when you are signed in.
Reading input
Open the Input box under the editor and type what your program should read. Each call to gets reads the next line, newline included, so chomp it off. With the box empty, or once every line is read, gets returns nil.
name = gets.to_s.chomp
Frequently asked questions
Is this online Ruby compiler free?
Yes. There is no sign-up and no limit on how much you can write. Signed-out visitors get a quick, usually invisible bot check when they press Run, and a fair-use cap of 5 runs a minute and 50 a day. Signing in raises it to 10 runs a minute.
Which version of Ruby does it run?
Ruby 3.0 (MRI, the standard interpreter) on Linux. Blocks, hashes with symbol keys, Struct, pattern matching with case and in, endless methods and keyword arguments all work. Features added after 3.0, such as Data classes and the it block parameter, do not.
Can I install gems or use Rails?
No. The playground runs one file against Ruby and its standard library. There is no gem install or Bundler and no network, so Rails and other gems are not available, but everything that ships with Ruby, such as json, set and date, is.
How do I read input in the Ruby playground?
Type it in the Input box under the editor before you press Run. gets reads one line at a time and returns nil when there is nothing left, and STDIN.read reads everything at once. To read a number, convert the line: gets.to_i.
Why did my program stop with a time-out?
Each run gets 10 seconds and 256 MB of memory. A program that goes past either is stopped. The usual cause is a loop that never ends, such as a while loop whose condition never turns false, or a loop do without a break.
Is my code saved or shared?
Your code is kept in your own browser so it is still there next time, and nowhere else. When you press Run it is sent to our code runner, run once in a sandbox, and thrown away. We do not store it or show it to anyone.