- Home
- Code Formatting Tools
- Scalafmt
Scalafmt
What it is
Scalafmt is a free, open-source formatter for Scala code that helps teams apply consistent formatting. It handles Scala 2, Scala 3, sbt files, and Scala scripts, with one selected dialect for each file. Formatting options go in a plain text `.scalafmt.conf` file using HOCON syntax. Since version 3.1.0, the version and `runner.dialect` settings must be specified explicitly. Scalafmt can run from an editor, build tool, or terminal. Documented editor integrations include IntelliJ, VS Code, Vim, NeoVim, Emacs, Sublime Text, and Eclipse; Metals supports formatting requests from editors. It integrates with sbt and documents integrations for Maven, Gradle, and Mill. The CLI’s check and test modes report misformatted code without writing changes. It also supports ignore files, changed-lines formatting, and a library API. IntelliJ range formatting uses its own formatter by default because Scalafmt focuses mainly on whole files and selected ranges may produce undesirable results. The project identifies its license as Apache-2.0.
For and against
For
- Free and open-source under Apache-2.0.
- Supports Scala 2, Scala 3, sbt, and Scala scripts.
- CLI check and test modes do not write changes.
- Integrates with editors and build tools.
- Includes a library API.
Against
- Configuration must specify version and `runner.dialect` since 3.1.0.
- IntelliJ range formatting defaults to IntelliJ’s own formatter.
- Selected-range formatting may produce undesirable results.
The verdict
Scalafmt offers multiple ways to format Scala files and check formatting without modifying them. Its whole-file focus and configuration requirements are relevant considerations, especially for IntelliJ range formatting.
Who it suits
Scalafmt suits Scala developers who want consistent formatting across a team and use an editor, build tool, or terminal workflow. Its documented integrations cover a range of editors and build tools.
Plans and prices
Free
Code formatter for Scala
Read 7 Oct 2026 · scalameta.org
On the record
- Build integrations
- Scalafmt integrates with sbt and has documented integrations for Maven, Gradle, and Mill.scalameta.org · read 7 Oct 2026
- Configuration
- Formatting options are set in a plain text .scalafmt.conf file using HOCON syntax.scalameta.org · read 7 Oct 2026
- Editor integrations
- The documentation describes use with IntelliJ, VS Code, Vim, NeoVim, Emacs, Sublime Text, and Eclipse, with Metals supporting formatting requests from editors.scalameta.org · read 7 Oct 2026
- File support
- Scalafmt can format Scala files as well as .sbt and .sc files.scalameta.org · read 7 Oct 2026
- Formatting checks
- The CLI offers check and test modes that report misformatted code without writing changes.scalameta.org · read 7 Oct 2026
- How to run it
- Scalafmt can run from an editor, build tool, or terminal.scalameta.org · read 7 Oct 2026
- IntelliJ limitation
- IntelliJ range formatting uses its own formatter by default because Scalafmt is primarily designed to format entire text files and selected ranges may produce undesirable results.scalameta.org · read 7 Oct 2026
- License
- The GitHub repository identifies the project license as Apache-2.0.github.com · read 7 Oct 2026
- Purpose
- Scalafmt is a code formatter for Scala that formats code consistently across a team.scalameta.org · read 7 Oct 2026
- Scala dialects
- The formatter supports Scala 2, Scala 3, and sbt-specific dialects, with one dialect selected for each file.scalameta.org · read 7 Oct 2026
- Security
- The official Scalafmt pages opened for this research do not state security certifications or compliance claims.scalameta.org · read 7 Oct 2026
- Support
- The project site links to a community Discord and GitHub, and the CLI help directs bug reports to GitHub issues.scalameta.org · read 7 Oct 2026
- Version requirement
- Since version 3.1.0, the version and runner.dialect settings must be specified explicitly in configuration.scalameta.org · read 7 Oct 2026