whatisgithub

What is rustfmt?

rust-lang/rustfmt — explained in plain English

Analysis updated 2026-06-24

6,827RustAudience · developerComplexity · 2/5Setup · easy

In one sentence

Official code formatter for the Rust programming language that automatically rewrites Rust source files to follow a consistent style. Run it before commits or wire it into CI to keep an entire codebase looking the same.

Mindmap

mindmap
  root((rustfmt))
    What it does
      Format Rust code
      Enforce style rules
      CI check mode
    Usage
      cargo fmt command
      Editor plugins
      Automated pipelines
    Configuration
      rustfmt.toml file
      Line length setting
      Indentation style
    Supported Editors
      VS Code
      Vim
      IntelliJ
      Emacs
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Automatically format all Rust files in a project with a single cargo fmt command before every commit.

USE CASE 2

Add a CI check that fails a pull request immediately if any submitted code is not correctly formatted.

USE CASE 3

Configure rustfmt.toml to enforce a custom line length or indentation style across an entire team.

USE CASE 4

Install an editor plugin so Rust code formats automatically every time a file is saved.

What is it built with?

Rustcargo

How does it compare?

rust-lang/rustfmtfacebook/saplingopenethereum/parity-ethereum
Stars6,8276,8356,837
LanguageRustRustRust
Setup difficultyeasymoderatehard
Complexity2/53/54/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Some advanced configuration options are only available when using the nightly Rust build rather than the stable release.

So what is it?

Rustfmt is the official code formatter for the Rust programming language. Its job is to automatically rewrite your Rust source files so they follow a consistent style, the same way you might use a spell-checker to clean up text. Developers run it before committing code so that everyone on a project writes code that looks the same, regardless of personal habits. The most common way to use it is through the Rust build tool: running cargo fmt in your project directory formats all the code in that project in one step. You can also run rustfmt directly on individual files, or pipe code through it on the command line. There are editor plugins for Vim, Emacs, Sublime Text, VS Code, IntelliJ, and others, so it can run automatically whenever you save a file. For teams, rustfmt has a check mode that exits with an error if any code is not formatted correctly, without changing anything. This is used in automated testing pipelines so that a pull request fails immediately if it contains unformatted code, keeping the whole codebase consistent without relying on people to remember to run the formatter manually. The tool is configurable through a file called rustfmt.toml in your project. You can adjust things like indentation, line length, and other style details. Some options are only available when using the nightly build of Rust rather than the stable release. By default, rustfmt follows the official Rust style guide. The project is open source and maintained by the Rust language team.

Copy-paste prompts

Prompt 1
How do I set up rustfmt in a GitHub Actions workflow to automatically reject pull requests that contain unformatted Rust code?
Prompt 2
Create a rustfmt.toml configuration file that sets max line length to 100 and uses 2-space indentation for my Rust project.
Prompt 3
Configure VS Code to run rustfmt automatically on save whenever I edit a Rust file.
Prompt 4
How do I use rustfmt's check mode in a pre-commit hook so formatting is verified locally before code is pushed?

Frequently asked questions

What is rustfmt?

Official code formatter for the Rust programming language that automatically rewrites Rust source files to follow a consistent style. Run it before commits or wire it into CI to keep an entire codebase looking the same.

What language is rustfmt written in?

Mainly Rust. The stack also includes Rust, cargo.

How hard is rustfmt to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is rustfmt for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.