For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /guide/cli/fmt.md.
  • English
  • fmt

    The rs fmt command formats files or checks whether they are formatted. For detailed usage, see Formatting.

    Usage

    rs fmt [options] [files/globs...]

    Pass files, directories, or glob patterns to choose what to format. When no paths are provided, rs fmt formats the current directory. See Formatting scope for path resolution and ignore rules.

    Examples:

    # Format files in the current directory
    rs fmt
    
    # Format specific files and directories
    rs fmt src package.json
    
    # Check formatting in CI
    rs fmt --check

    rs format is an alias for rs fmt:

    rs format

    Options

    --check

    Check whether files are formatted without changing them. The output lists files with formatting issues and includes a human-friendly summary, making this option useful in CI:

    rs fmt . --check

    --check cannot be combined with --write or --list-different.

    The command uses the following exit codes:

    CodeMeaning
    0All matched files are formatted.
    1One or more matched files have formatting issues.
    2rs fmt could not run or encountered a formatting error.

    -h, --help

    Display usage and option information without formatting files:

    rs fmt --help

    --list-different

    Print the paths of unformatted files without the summary produced by --check. This is useful when another command needs to consume the output:

    rs fmt . --list-different

    The option uses the same exit codes as --check and cannot be combined with --write or --check.

    --parallel-workers <count>

    Set the maximum number of formatting workers to a positive integer:

    rs fmt . --parallel-workers 4

    When this option is omitted, rs fmt automatically chooses up to eight workers based on the available CPU parallelism and the number of matched files. Set a lower value to limit CPU or memory usage in constrained environments.

    --stdin-filepath <path>

    Format content received from stdin as if it were saved at <path>. The path determines the parser and matching configuration overrides, but it does not need to exist on disk. The formatted content is written to stdout:

    cat src/index.ts | rs fmt --stdin-filepath src/index.ts

    --stdin-filepath cannot be combined with file arguments or with --write, --check, or --list-different. See Formatting stdin for details.

    --write

    Write formatted files in place. This is the default mode, so specifying --write is optional:

    rs fmt src --write

    --write cannot be combined with --check or --list-different.