Practice Ruby online
A free Ruby editor that runs real Ruby 4.0 in your browser. Write code, press Run, and type your answers when the program asks with gets. There's nothing to install and no account to make.
Ruby 4.0 · free · no sign-up · runs in your browser
Ruby practice problems for beginners
Each one opens in the editor above as a working program with something left for you to finish.
- problem 1
Greet me
Ask for a name and an age with gets, then print one sentence that uses both.
- problem 2
Even or odd
Read a whole number and say whether it's even or odd. Ruby has even? and odd? built in.
- problem 3
FizzBuzz
Print 1 to 30, but Fizz for multiples of 3, Buzz for multiples of 5, and FizzBuzz for both.
- problem 4
Count the words
Count how many times each word appears in a sentence, then print them, most common first.
- problem 5
A bank account
Finish the Account class so deposit adds money and withdraw refuses to go below zero.
A free online Ruby compiler that runs in your browser
- Real Ruby 4.0 with the standard library (json, set, date, erb and more)
- gets works: the program pauses and you type your answer in the console
- Errors point to the exact line, the way Ruby prints them
- Every run starts a fresh Ruby, so nothing from the last run gets in the way
- Your code is remembered in your browser, and Share gives you a link
- The free Ruby course in Courses teaches it from the first puts
Ruby editor questions
Is this Ruby editor free?
Yes. It's free, with no sign-up, no ads and no tracking. Your code runs in your own browser and isn't sent anywhere unless you press Share to make a link.
Which version of Ruby is it?
Ruby 4.0, the real Ruby interpreter compiled to WebAssembly (ruby.wasm, from the Ruby project itself), with the standard library. Gems from the internet can't be installed.
Does gets work?
Yes. When your program calls gets, it pauses and a line to type on appears in the console. Press Enter and the program carries on, just like in a terminal. Remember the answer ends with a newline: gets.chomp takes it off, and gets.to_i turns it into a number.
Can I run Rails here?
No: Rails needs a server, a database and gems. What you can do here is everything Ruby itself does, and the Ruby course ends by building a tiny web framework from scratch, which shows how Rails and Sinatra work inside.
Does it work on a Chromebook, iPad or phone?
Yes, in any up-to-date browser: Chrome, Safari, Edge or Firefox, including school Chromebooks. The first run downloads about 10 MB, then your browser keeps it, so later visits start fast.
Is my code saved?
Your code is remembered in your browser, so it's there when you come back on the same device. To keep a copy or send it to someone, press Share for a link, or Copy.
Are there any limits?
A program can run for 10 seconds (time spent waiting for you to type doesn't count), and programs can be up to 20,000 characters. That's plenty for practice problems, school assignments and small projects.
Want a coach while you practice?
HopeCoders teaches Ruby 1-on-1 for all ages, from first programs to school projects. Every coach is background checked, and sessions happen in person across Greater Los Angeles, from Pasadena, Burbank and Beverly Hills to the South Bay, Long Beach and north Orange County, or online over Zoom.