Online Rust compiler

Compile and run Rust online free, no sign-up: write fn main(), give it input on stdin and see the output, compiler errors and run time in your browser.

How do I run Rust code online?

This is an online Rust compiler: write a program with fn main(), put its input in the Input box and press Run. It is compiled with rustc and run on the server, and you see the output, the borrow checker's and compiler's errors, or the panic, and the run time — free, with no sign-up.

How it works

  1. Write your program. A Rust program starts at fn main() and is compiled as a single file with the standard library only — there is no Cargo here, so crates such as rand or regex cannot be used.
  2. Give it input. Read everything with io::stdin().read_to_string(&mut input) (bring in std::io::Read), then walk input.lines() or input.split_whitespace() and parse with .parse::<i64>().unwrap(). Put every line the program reads in the Input box before you run it.
  3. 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 Rust 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 Rust before setting it up.

Frequently asked questions

Can I use crates from crates.io?
No. The code is compiled as one file with rustc, without Cargo, so only std is available. Most practice programs need nothing else: std::collections has HashMap, BTreeMap, VecDeque and BinaryHeap.
What does "thread 'main' panicked" mean?
The program stopped on a panic: an unwrap() on None or Err, an index past the end of a vector, or integer overflow in a debug build. The message says which line; replace that unwrap() with a match or unwrap_or to handle the case.
Is this online compiler free, and do I need an account?
It is free and needs no account. Without one, a network gets up to 60 runs an hour, and the first run asks a quick check that you are a person. A free account removes the check and gives you an allowance of your own, which matters in a college lab where everyone shares one connection.
Can my program ask for input while it runs?
No. The program runs once on the server, start to finish, so everything it reads from standard input must be in the Input box before you press Run — one line there is one line the program can read. A program that waits for input the box does not have either fails at the end of input or runs until it is stopped.
Is my code saved or shared?
Your code is kept in this browser as you type, per language, so it is still there when you come back. When you press Run it is sent to be compiled and run — SQL on CodeKairo's own server, the other languages on a code-execution service — and only the output comes back. CodeKairo does not store it or show it to anyone.
What are the limits?
A program can be up to 64 KB and its input up to 16 KB. A run that takes too long is stopped and reported as Time limit exceeded — usually an endless loop, or a program waiting for input that is not in the box. There is no file system to keep files in and no way to install packages: each language has its standard library.