Menu

Online Rust Compiler

Write, run, and share code snippets — no setup required.

main.rs
Output
Click Run to see the output here.

Run Rust online in your browser

A free online Rust playground and compiler. Write Rust in your browser, hit Run, and rustc compiles and executes your program in seconds. No local rustup, no cargo project, no target triple to configure first.

The editor is built on the same engine as VS Code, so Rust syntax highlighting, autocompletion, and diagnostic squiggles all work. Code compiles with rustc on Alpine Linux, with the standard library available — std::collections, std::io, std::fs, Option, Result, Vec, HashMap, Iterator. Good for exploring ownership, testing a trait implementation, or confirming how a lifetime propagates.

What makes this Rust playground useful

  • Instant Rust compilation — write code, press Run, and see output from rustc in seconds, no Cargo.toml or target directory needed.
  • Full Rust syntax highlighting, autocompletion, and clear compiler diagnostics, powered by the same editor engine as VS Code, with rustc's famously helpful error messages.
  • Stdin input is supported. std::io::stdin().read_line(&mut buf), BufRead::lines, and the read_to_string pattern all read from the playground's input box. No rustup, cargo, or MSVC linker on your end.
  • Rust compiler (rustc) on Alpine Linux — write Rust with ownership, lifetimes, and pattern matching, and get the borrow checker's feedback in seconds.

What you can build in the Rust playground

  • Ownership, borrowing, and lifetimes: the idioms that make Rust memory-safe, with rustc telling you exactly what you violated.
  • Traits, generics, and pattern matching with enums: idiomatic Rust you can test one impl block at a time, plus Option and Result composition.
  • Quick Rust experiments: test an iterator chain, try a match arm, verify a trait bound, or confirm how a closure captures its environment.

Online Rust compiler FAQ

Is the online Rust compiler free?
Yes, the Rust playground is free to use. No sign-up, no rustup to install, and no cargo project to scaffold — open the page and compile.
Do I need rustup or cargo installed?
No install needed. You don't need rustup, cargo, or a Rust toolchain on your machine. The online Rust compiler compiles your code with rustc on Alpine Linux and runs it in seconds.
Does the Rust playground work on mobile and Chromebooks?
Yes. The Rust playground runs in any modern browser, on desktop, tablet or mobile. Good for compiling Rust from a Chromebook or machine where you can't install rustup.
Can I use std::io::stdin() in the online Rust compiler?
Yes. std::io::stdin().read_line(&mut buf), io::BufRead::lines, and read_to_string all read your typed lines the same way they would when you run cargo run locally and type at the terminal. Useful for practicing Rust ownership patterns on real input.
How do I learn Rust after trying the playground?
Edit the sample Rust code, press Run, and iterate. When you want something more structured, Coddy's interactive Rust course takes you from ownership and borrowing to traits, generics, and error handling with hands-on exercises.