Format
Rewrites your Rust with rustfmt, the official Rust formatter. It fixes indentation, spacing, and line breaks to match the standard Rust style.
fn main(){let x=1;println!("{}",x)}Afterfn main() {
let x = 1;
println!("{}", x)
}Paste your Rust and get it back in the standard Rust style. The formatter is rustfmt, the same tool that ships with Rust, running in your browser, so your code stays on your device.
Format uses rustfmt, the official Rust formatter. Options apply to Format.
rustfmt applies the standard Rust style. It fixes indentation, tidies spacing, wraps long lines to fit your width, and groups and orders use declarations so every Rust file looks the same. This tool runs rustfmt in your browser and changes only the layout, never what the program does.
Rewrites your Rust with rustfmt, the official Rust formatter. It fixes indentation, spacing, and line breaks to match the standard Rust style.
fn main(){let x=1;println!("{}",x)}Afterfn main() {
let x = 1;
println!("{}", x)
}Set the line width rustfmt aims for. Its default is 100 characters. Pick a smaller width for narrow screens or a larger one to keep more code on one line.
Long call on one lineAfterWrapped to fit the widthChoose the Rust edition of your code (2015, 2018, 2021, or 2024). This tells rustfmt which syntax to expect so newer code parses and formats correctly.
Edition 2015 defaultAfterParsed as your editionrustfmt helps whenever you have Rust code that is not yet in the standard style. These are the cases that come up most:
New to the language? Start at rust-lang.org, then read The Rust Book, the free guide that walks you through the language from the ground up.
Want to change how the output looks? Every setting rustfmt understands, and what each one does, is written up in the rustfmt configuration guide.
If you work across languages, these formatters run the same way, right in your browser: