Formatter Validator Minifier Escape / Unescape JSON ↔ String JSON ↔ YAML JSON → CSV NDJSON / JSON Lines JSON → Types JSON ↔ XML JSON Diff JSON Patch Canonicalize (RFC 8785) Schema Validator Schema Generator JSONPath Tester JWT Decoder JSON Errors Schemas More Tools
JSONTools / Schema registry / rustfmt
Schema registry

rustfmt

rustfmt, a tool to format Rust code. Documentation: https://rust-lang.github.io/rustfmt

rustfmt.toml.rustfmt.toml

Check your file against this schema

Opens the validator with this schema already loaded. Paste your rustfmt.toml and it validates in your browser — nothing is uploaded.

Validate a rustfmt.toml → View raw schema

Fields

Generated directly from the schema, following local $refs, to two levels of nesting.

Field Type Description
array_widthintegerMaximum width of an array literal before falling back to vertical formatting. Possible values: any positive integer that is less than or equal to the value specified for `max_width` Stable: Yes By default this option is set as a percentage
default: 60
attr_fn_like_widthintegerMaximum width of the args of a function-like attributes before falling back to vertical formatting. Possible values: any positive integer that is less than or equal to the value specified for `max_width` Stable: Yes By default this option
default: 70
binop_separatorstringWhere to put a binary operator when a binary expression goes multiline. Stable: No (tracking issue: [#3368](https://github.com/rust-lang/rustfmt/issues/3368)) #### `"Front"` (default): ```rust fn main() { let or =
default: "Front"
one of: "Front", "Back"
blank_lines_lower_boundintegerMinimum number of blank lines which must be put between items. If two items have fewer blank lines between them, additional blank lines are inserted. Possible values: *unsigned integer* Stable: No (tracking issue
default: 0
blank_lines_upper_boundintegerMaximum number of blank lines which can be put between items. If more than this number of consecutive empty lines are found, they are trimmed down to match this integer. Possible values: any non-negative integer Stable: No (tracking issue
default: 1
brace_stylestringBrace style for items Stable: No (tracking issue: [#3376](https://github.com/rust-lang/rustfmt/issues/3376)) ### Functions #### `"SameLineWhere"` (default): ```rust fn lorem() { // body } fn lorem(ipsum: usize) { // body } fn
default: "SameLineWhere"
one of: "AlwaysNextLine", "PreferSameLine", "SameLineWhere"
chain_widthintegerMaximum width of a chain to fit on one line. Possible values: any positive integer that is less than or equal to the value specified for `max_width` Stable: Yes By default this option is set as a percentage of `max_width` provided by
default: 60
colorstringWhether to use colored output or not. Stable: No (tracking issue: [#3385](https://github.com/rust-lang/rustfmt/issues/3385))
default: "Auto"
one of: "Auto", "Always", "Never"
combine_control_exprbooleanCombine control expressions with function calls. Stable: No (tracking issue: [#3369](https://github.com/rust-lang/rustfmt/issues/3369)) #### `true` (default): ```rust fn example() { // If foo!(if x { foo(); } else { bar(); }); // IfLet
default: true
comment_widthintegerMaximum length of comments. No effect unless `wrap_comments = true`. Possible values: any positive integer Stable: No (tracking issue: [#3349](https://github.com/rust-lang/rustfmt/issues/3349)) **Note:** A value of `0` results in
default: 80
condense_wildcard_suffixesbooleanReplace strings of _ wildcards by a single .. in tuple patterns Stable: No (tracking issue: [#3384](https://github.com/rust-lang/rustfmt/issues/3384)) #### `false` (default): ```rust fn main() { let (lorem, ipsum, _, _) = (1, 2, 3, 4); let
default: false
control_brace_stylestringBrace style for control flow constructs Stable: No (tracking issue: [#3377](https://github.com/rust-lang/rustfmt/issues/3377)) #### `"AlwaysSameLine"` (default): ```rust fn main() { if lorem { println!("ipsum!"); } else {
default: "AlwaysSameLine"
one of: "AlwaysNextLine", "AlwaysSameLine", "ClosingNextLine"
disable_all_formattingbooleanDon't reformat anything. Note that this option may be soft-deprecated in the future once the [ignore](#ignore) option is stabilized. Nightly toolchain users are encouraged to use [ignore](#ignore) instead when possible. Stable: Yes
default: false
editionstringSpecifies which edition is used by the parser. Stable: Yes The `edition` option determines the Rust language edition used for parsing the code. This is important for syntax compatibility but does not directly control formatting behavior
default: "2015"
one of: "2015", "2018", "2021", "2024"
empty_item_single_linebooleanPut empty-body functions and impls on a single line Stable: No (tracking issue: [#3356](https://github.com/rust-lang/rustfmt/issues/3356)) #### `true` (default): ```rust fn lorem() {} impl Lorem {} ``` #### `false`: ```rust fn lorem() { }
default: true
enum_discrim_align_thresholdintegerThe maximum length of enum variant having discriminant, that gets vertically aligned with others. Variants without discriminants would be ignored for the purpose of alignment. Note that this is not how much whitespace is inserted, but
default: 0
error_on_line_overflowbooleanError if Rustfmt is unable to get all lines within `max_width`, except for comments and string literals. If this happens, then it is a bug in Rustfmt. You might be able to work around the bug by refactoring your code to avoid long/complex
default: false
error_on_unformattedbooleanError if unable to get comments or string literals within `max_width`, or they are left with trailing whitespaces. Stable: No (tracking issue: [#3392](https://github.com/rust-lang/rustfmt/issues/3392))
default: false
fn_args_layoutstringThis option is deprecated and has been renamed to `fn_params_layout` to better communicate that it affects the layout of parameters in function signatures. Stable: Yes #### `"Tall"` (default): ```rust trait Lorem { fn lorem(ipsum: Ipsum
default: "Tall"
one of: "Compressed", "Tall", "Vertical"
fn_call_widthintegerMaximum width of the args of a function call before falling back to vertical formatting. Possible values: any positive integer that is less than or equal to the value specified for `max_width` Stable: Yes By default this option is set as a
default: 60
fn_params_layoutstringControl the layout of parameters in function signatures. Stable: Yes #### `"Tall"` (default): ```rust trait Lorem { fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet); fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) { //
default: "Tall"
one of: "Compressed", "Tall", "Vertical"
fn_single_linebooleanPut single-expression functions on a single line Stable: No (tracking issue: [#3358](https://github.com/rust-lang/rustfmt/issues/3358)) #### `false` (default): ```rust fn lorem() -> usize { 42 } fn lorem() -> usize { let ipsum = 42; ipsum
default: false
force_explicit_abibooleanAlways print the abi for extern items Stable: Yes **Note:** Non-"C" ABIs are always printed. If `false` then "C" is removed. #### `true` (default): ```rust extern "C" { pub static lorem: c_int; } ``` #### `false`: ```rust extern { pub
default: true
force_multiline_blocksbooleanForce multiline closure and match arm bodies to be wrapped in a block Stable: No (tracking issue: [#3374](https://github.com/rust-lang/rustfmt/issues/3374)) #### `false` (default): ```rust fn main() { result.and_then(|maybe_value| match
default: false
format_code_in_doc_commentsbooleanFormat code snippet included in doc comments. Stable: No (tracking issue: [#3348](https://github.com/rust-lang/rustfmt/issues/3348)) #### `false` (default): ```rust /// Adds one to the number given. /// /// # Examples /// /// ```rust ///
default: false
doc_comment_code_block_widthintegerMax width for code snippets included in doc comments. Only used if `format_code_in_doc_comments` is true. Possible values: any positive integer that is less than or equal to the value specified for `max_width` Stable: No (tracking issue
default: 100
format_generated_filesbooleanFormat generated files. A file is considered generated if any of the first several lines contain a `@generated` comment marker. The number of lines to check is configured by `generated_marker_line_search_limit`. By default, generated files
default: true
generated_marker_line_search_limitintegerNumber of lines to check for a `@generated` pragma header, starting from the top of the file. Setting this value to `0` will treat all files as non-generated. When`format_generated_files` is `true`, this option has no effect. Possible
default: 5
format_macro_matchersbooleanFormat the metavariable matching patterns in macros. Stable: No (tracking issue: [#3354](https://github.com/rust-lang/rustfmt/issues/3354)) #### `false` (default): ```rust macro_rules! foo { ($a: ident : $b: ty) => { $a(42): $b; }; ($a
default: false
format_macro_bodiesbooleanFormat the bodies of declarative macro definitions. Stable: No (tracking issue: [#3355](https://github.com/rust-lang/rustfmt/issues/3355)) #### `true` (default): ```rust macro_rules! foo { ($a: ident : $b: ty) => { $a(42): $b; }; ($a
default: true
skip_macro_invocationsanySkip formatting the bodies of macro invocations with the following names. rustfmt will not format any macro invocation for macros with names set in this list. Including the special value "*" will prevent any macro invocations from being
default: []
format_stringsbooleanFormat string literals where necessary Stable: No (tracking issue: [#3353](https://github.com/rust-lang/rustfmt/issues/3353)) #### `false` (default): ```rust fn main() { let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem
default: false
hard_tabsbooleanUse tab characters for indentation, spaces for alignment Stable: Yes #### `false` (default): ```rust fn lorem() -> usize { 42 // spaces before 42 } ``` #### `true`: ```rust fn lorem() -> usize { 42 // tabs before 42 } ``` See also
default: false
hex_literal_casestringControl the case of the letters in hexadecimal literal values Stable: No (tracking issue: [#5081](https://github.com/rust-lang/rustfmt/issues/5081))
default: "Preserve"
one of: "Preserve", "Upper", "Lower"
float_literal_trailing_zerostringControl the presence of trailing zero in floating-point literal values Stable: No (tracking issue: [#6471](https://github.com/rust-lang/rustfmt/issues/6471)) #### `Preserve` (default): Leave the literal as-is. ```rust fn main() { let
default: "Preserve"
one of: "Preserve", "Always", "IfNoPostfix", "Never"
hide_parse_errorsbooleanThis option is deprecated and has been renamed to `show_parse_errors` to avoid confusion around the double negative default of `hide_parse_errors=false`. Stable: No (tracking issue: [#3390](https://github.com/rust-lang/rustfmt/issues/3390))
default: false
show_parse_errorsbooleanShow parse errors if the parser failed to parse files. Stable: No (tracking issue: [#5977](https://github.com/rust-lang/rustfmt/issues/5977))
default: true
ignoreanySkip formatting files and directories that match the specified pattern. The pattern format is the same as [.gitignore](https://git-scm.com/docs/gitignore#_pattern_format). Be sure to use Unix/forwardslash `/` style paths. This path style
imports_indentstringIndent style of imports Stable: No (tracking issue: [#3360](https://github.com/rust-lang/rustfmt/issues/3360)) #### `"Block"` (default): ```rust use foo::{ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
default: "Block"
one of: "Block", "Visual"
imports_layoutstringItem layout inside a imports block Stable: No (tracking issue: [#3361](https://github.com/rust-lang/rustfmt/issues/3361)) #### `"Mixed"` (default): ```rust use foo::{xxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzzzz}; use foo::{
default: "Mixed"
one of: "Horizontal", "HorizontalVertica…, "Mixed", "Vertical"
indent_stylestringIndent on expressions or items. Stable: No (tracking issue: [#3346](https://github.com/rust-lang/rustfmt/issues/3346)) ### Array #### `"Block"` (default): ```rust fn main() { let lorem = vec![ "ipsum", "dolor", "sit", "amet"
default: "Block"
one of: "Block", "Visual"
inline_attribute_widthintegerWrite an item and its attribute on the same line if their combined width is below a threshold Possible values: any positive integer Stable: No (tracking issue: [#3343](https://github.com/rust-lang/rustfmt/issues/3343)) ### Example #### `0`
default: 0
match_arm_blocksbooleanControls whether arm bodies are wrapped in cases where the first line of the body cannot fit on the same line as the `=>` operator. The Style Guide requires that bodies are block wrapped by default if a line break is required after the
default: true
match_arm_leading_pipesstringControls whether to include a leading pipe on match arms Stable: Yes #### `Never` (default): ```rust // Leading pipes are removed from this: // fn foo() { // match foo { // | "foo" | "bar" => {} // | "baz" // | "something relatively long"
default: "Never"
one of: "Always", "Never", "Preserve"
match_arm_indentbooleanControls whether match arms are indented. If disabled, match arms will be formatted at the same indentation level as the outer `match` statement. Meaning that match blocks will only be indented once, not twice. Stable: No (tracking issue
default: true
match_block_trailing_commabooleanPut a trailing comma after a block based match arm (non-block arms are not affected) Stable: Yes #### `false` (default): ```rust fn main() { match lorem { Lorem::Ipsum => { println!("ipsum"); } Lorem::Dolor => println!("dolor"), } } ```
default: false
max_widthintegerMaximum width of each line Possible values: any positive integer Stable: Yes See also `error_on_line_overflow`.
default: 100
merge_derivesbooleanMerge multiple derives into a single one. Stable: Yes #### `true` (default): ```rust #[derive(Eq, PartialEq, Debug, Copy, Clone)] pub enum Foo {} ``` #### `false`: ```rust #[derive(Eq, PartialEq, Debug, Copy, Clone)] pub enum Bar {}
default: true
imports_granularitystringControls how imports are structured in `use` statements. Imports will be merged or split to the configured level of granularity. Similar to other `import` related configuration options, this option operates within the bounds of
default: "Preserve"
one of: "Preserve", "Crate", "Module", "Item", "One"
merge_importsbooleanThis option is deprecated. Use `imports_granularity = "Crate"` instead. Stable: undefined #### `false` (default): ```rust use foo::{a, c, d}; use foo::{b, g}; use foo::{e, f}; ``` #### `true`: ```rust use foo::{a, b, c, d, e, f, g}; ```
default: false
newline_stylestringUnix or Windows line endings Stable: Yes #### `Auto` (default): The newline style is detected automatically on a per-file basis. Files with mixed line endings will be converted to the first detected line ending style. #### `Native` Line
default: "Auto"
one of: "Auto", "Native", "Unix", "Windows"
normalize_commentsbooleanConvert /* */ comments to // comments where possible Stable: No (tracking issue: [#3350](https://github.com/rust-lang/rustfmt/issues/3350)) #### `false` (default): ```rust // Lorem ipsum: fn dolor() -> usize {} /* sit amet: */ fn
default: false
normalize_doc_attributesbooleanConvert `#![doc]` and `#[doc]` attributes to `//!` and `///` doc comments. Stable: No (tracking issue: [#3351](https://github.com/rust-lang/rustfmt/issues/3351)) #### `false` (default): ```rust #![doc = "Example documentation"] #[doc =
default: false
overflow_delimited_exprbooleanWhen structs, slices, arrays, and block/array-like macros are used as the last argument in an expression list, allow them to overflow (like blocks/closures) instead of being indented on a new line. Stable: No (tracking issue
default: false
remove_nested_parensbooleanRemove nested parens. Stable: Yes #### `true` (default): ```rust fn main() { (foo()); } ``` #### `false`: ```rust fn main() { (foo()); ((((foo())))); } ```
default: true
reorder_impl_itemsbooleanReorder impl items. `type` and `const` are put first, then macros and methods. Stable: No (tracking issue: [#3363](https://github.com/rust-lang/rustfmt/issues/3363)) #### `false` (default) ```rust struct Dummy; impl Iterator for Dummy { fn
default: false
reorder_importsbooleanReorder import and extern crate statements alphabetically in groups (a group is separated by a newline). Stable: Yes #### `true` (default): ```rust use dolor; use ipsum; use lorem; use sit; ``` #### `false`: ```rust use lorem; use ipsum
default: true
group_importsstringControls the strategy for how consecutive imports are grouped together. Controls the strategy for grouping sets of consecutive imports. Imports may contain newlines between imports and still be grouped together as a single set, but other
default: "Preserve"
one of: "Preserve", "StdExternalCrate", "One"
reorder_modulesbooleanReorder `mod` declarations alphabetically in group. Stable: Yes #### `true` (default) ```rust mod a; mod b; mod dolor; mod ipsum; mod lorem; mod sit; ``` #### `false` ```rust mod b; mod a; mod lorem; mod ipsum; mod dolor; mod sit; ```
default: true
required_versionanyRequire a specific version of rustfmt. If you want to make sure that the specific version of rustfmt is used in your CI, use this option. Possible values: `semver` compliant values, such as defined on [semver.org](https://semver.org/)
default: "CARGO_PKG_VERSION"
short_array_element_width_thresholdintegerThe width threshold for an array element to be considered "short". The layout of an array is dependent on the length of each of its elements. If the length of every element in an array is below this threshold (all elements are "short")
default: 10
skip_childrenbooleanDon't reformat out of line modules Stable: No (tracking issue: [#3389](https://github.com/rust-lang/rustfmt/issues/3389))
default: false
single_line_if_else_max_widthintegerMaximum line length for single line if-else expressions. A value of `0` (zero) results in if-else expressions always being broken into multiple lines. Note this occurs when `use_small_heuristics` is set to `Off`. Possible values: any
default: 50
single_line_let_else_max_widthintegerMaximum line length for single line let-else statements. See the [let-else statement section of the Rust Style Guide](https://github.com/rust-lang/rust/blob/master/src/doc/style-guide/src/statements.md#else-blocks-let-else-statements) for
default: 50
space_after_colonbooleanLeave a space after the colon. Stable: No (tracking issue: [#3366](https://github.com/rust-lang/rustfmt/issues/3366)) #### `true` (default): ```rust fn lorem<T: Eq>(t: T) { let lorem: Dolor = Lorem { ipsum: dolor, sit: amet, }; } ``` ####
default: true
space_before_colonbooleanLeave a space before the colon. Stable: No (tracking issue: [#3365](https://github.com/rust-lang/rustfmt/issues/3365)) #### `false` (default): ```rust fn lorem<T: Eq>(t: T) { let lorem: Dolor = Lorem { ipsum: dolor, sit: amet, }; } ```
default: false
spaces_around_rangesbooleanPut spaces around the .., ..=, and ... range operators Stable: No (tracking issue: [#3367](https://github.com/rust-lang/rustfmt/issues/3367)) #### `false` (default): ```rust fn main() { let lorem = 0..10; let ipsum = 0..=10; match lorem {
default: false
struct_field_align_thresholdintegerThe maximum diff of width between struct fields to be aligned with each other. Possible values: any non-negative integer Stable: No (tracking issue: [#3371](https://github.com/rust-lang/rustfmt/issues/3371)) #### `0` (default): ```rust
default: 0
struct_lit_single_linebooleanPut small struct literals on a single line Stable: No (tracking issue: [#3357](https://github.com/rust-lang/rustfmt/issues/3357)) #### `true` (default): ```rust fn main() { let lorem = Lorem { foo: bar, baz: ofo }; } ``` #### `false`
default: true
struct_lit_widthintegerMaximum width in the body of a struct literal before falling back to vertical formatting. A value of `0` (zero) results in struct literals always being broken into multiple lines. Note this occurs when `use_small_heuristics` is set to
default: 18
struct_variant_widthintegerMaximum width in the body of a struct variant before falling back to vertical formatting. A value of `0` (zero) results in struct literals always being broken into multiple lines. Note this occurs when `use_small_heuristics` is set to
default: 35
style_editionanyControls the edition of the [Rust Style Guide] to use for formatting ([RFC 3338]) Possible values: `"2015"`, `"2018"`, `"2021"`, `"2024"` (unstable variant) Stable: No This option is inferred from the `edition` if not specified. See [Rust
default: "2015"
tab_spacesintegerNumber of spaces per tab Possible values: any positive integer Stable: Yes #### `4` (default): ```rust fn lorem() { let ipsum = dolor(); let sit = vec![ "amet consectetur adipiscing elit amet", "consectetur adipiscing elit amet
default: 4
trailing_commastringHow to handle trailing commas for lists Stable: No (tracking issue: [#3379](https://github.com/rust-lang/rustfmt/issues/3379)) #### `"Vertical"` (default): ```rust fn main() { let Lorem { ipsum, dolor, sit } = amet; let Lorem { ipsum
default: "Vertical"
one of: "Always", "Never", "Vertical"
trailing_semicolonbooleanAdd trailing semicolon after break, continue and return Stable: No (tracking issue: [#3378](https://github.com/rust-lang/rustfmt/issues/3378)) #### `true` (default): ```rust fn foo() -> usize { return 0; } ``` #### `false`: ```rust fn
default: true
type_punctuation_densitystringDetermines if `+` or `=` are wrapped in spaces in the punctuation of types Stable: No (tracking issue: [#3364](https://github.com/rust-lang/rustfmt/issues/3364)) #### `"Wide"` (default): ```rust fn lorem<Ipsum: Dolor + Sit = Amet>() { //
default: "Wide"
one of: "Compressed", "Wide"
unstable_featuresbooleanEnable unstable features on the unstable channel. Stable: No (tracking issue: [#3387](https://github.com/rust-lang/rustfmt/issues/3387))
default: false
use_field_init_shorthandbooleanUse field initialize shorthand if possible. Stable: Yes #### `false` (default): ```rust struct Foo { x: u32, y: u32, z: u32, } fn main() { let x = 1; let y = 2; let z = 3; let a = Foo { x, y, z }; let b = Foo { x: x, y: y, z: z }; } ```
default: false
use_small_heuristicsstringThis option can be used to simplify the management and bulk updates of the granular width configuration settings (`fn_call_width`, `attr_fn_like_width`, `struct_lit_width`, `struct_variant_width`, `array_width`, `chain_width`
default: "Default"
one of: "Default", "Off", "Max"
use_try_shorthandbooleanReplace uses of the try! macro by the ? shorthand Stable: Yes #### `false` (default): ```rust fn main() { let lorem = ipsum.map(|dolor| dolor.sit())?; let lorem = try!(ipsum.map(|dolor| dolor.sit())); } ``` #### `true`: ```rust fn main() {
default: false
versionstringThis option is deprecated and has been replaced by `style_edition`. `version = "One"` is equivalent to `style_edition = "(2015|2018|2021)"` and `version = "Two"` is equivalent to `style_edition = "2024"` Stable: No (tracking issue
default: "One"
one of: "One", "Two"
where_single_linebooleanForces the `where` clause to be laid out on a single line. Stable: No (tracking issue: [#3359](https://github.com/rust-lang/rustfmt/issues/3359)) #### `false` (default): ```rust impl<T> Lorem for T where Option<T>: Ipsum, { // body } ```
default: false
wrap_commentsbooleanBreak comments to fit on the line Note that no wrapping will happen if: 1. The comment is the start of a markdown header doc comment 2. A URL was found in the comment Stable: No (tracking issue
default: false

What we found in this schema

Specification sections for the keywords in this schema

Keyword Document Section
$commentJSON Schema Core, draft 2020-12§8.3 — Comments With "$comment"
$idJSON Schema Core, draft 2020-12§8.2.1 — The "$id" Keyword
$schemaJSON Schema Core, draft 2020-12§8.1.1 — "$schema"
defaultJSON Schema Validation, draft 2020-12§9.2 — "default"
descriptionJSON Schema Validation, draft 2020-12§9.1 — "title" and "description"
enumJSON Schema Validation, draft 2020-12§6.1.2 — "enum"
propertiesJSON Schema Core, draft 2020-12§10.3.2.1 — "properties"
typeJSON Schema Validation, draft 2020-12§6.1.1 — "type"

Documents

Attribution

This schema comes from SchemaStore, distributed under the Apache License 2.0. Copyright 2015–present Mads Kristensen and contributors. View the original file. The field table and audit on this page are generated by JSONTools.tools; the schema itself is unmodified.

← All schemas