Online Ruby compiler
Run Ruby code online free, no sign-up: write a Ruby script, read input with gets and see the output, errors and run time in your browser.
How do I run Ruby code online?
This is an online Ruby compiler and interpreter: write a script, put its input in the Input box and press Run, and you see what it printed, the exception and its backtrace if one was raised, and the run time — free, with no sign-up.
How it works
- Write your program. A Ruby program is a script run from the top — define methods and classes, then call them below. puts prints with a newline, print without one and p shows a value as Ruby sees it, quotes and all.
- Give it input. gets reads one line, newline included (gets.chomp drops it), and returns nil once the input has run out. gets.split.map(&:to_i) turns a line of numbers into an array; $stdin.read reads everything at once. Put every line the program reads in the Input box before you run it.
- Run it. Press Run or Ctrl+Enter. You get what the program printed, any compiler or runtime error, and how long it ran. The first run without an account asks a quick check that you are a person.
Who it is for
Anyone writing Ruby who wants it run now: a student checking a lab program or an exam answer, someone on a machine where nothing can be installed, or a learner trying Ruby before setting it up.