shfmt
github.com
- Free plan
- Windows
- macOS
- Linux
- Self-hosted
What shfmt is
shfmt is a free, open-source formatter for shell programs. It belongs to a project that also includes a shell parser and interpreter, and supports POSIX Shell, Bash, Zsh, mksh, and Bats. A consistent default style can be adjusted with flags for indentation, case indentation, binary-operator placement, redirect spacing, block placement, and minification. shfmt formats files or standard input, processes directories recursively, and can list, write, or diff files whose formatting differs. When parser or printer flags are absent, it reads options from EditorConfig files. The project also describes syntax checking that can replace bash -n: scripts are statically parsed and must use valid UTF-8. Installation routes include packages for Alpine, Arch, Debian, Docker, Fedora, FreeBSD, Homebrew, MacPorts, NixOS, OpenSUSE, PyPI, Scoop, Snapcraft, Void, and webi. Editor integrations include JetBrains plugins, micro, NeoVim, VS Code, Emacs, and Trunk. Other integrations include a Prettier plugin, GitHub Action, Markdown formatter plugin, and pre-commit hook. It supports ignore files and a library API.
Who it suits
shfmt suits shell developers who want consistent formatting, syntax checking, editor integration, or automation in repositories. Its listed language support covers common shell variants and Bats.
Good to know, and what to watch
- Supports POSIX Shell, Bash, Zsh, mksh, and Bats
- Formats files, input streams, and directories
- Reads options from EditorConfig
- Offers editor and automation integrations
- Provides a library API
- Formatting cannot be disabled for selected line ranges
- Scripts must use valid UTF-8
- The project avoids adding many formatting options
Plans
Every plan and priceshfmt
Open source
The verdict
shfmt combines formatting, parsing, syntax checking, and integrations for shell-focused workflows. Its fixed approach to formatting may not suit projects needing per-line exclusions.
What the maker publishes
- Configuration
- shfmt reads formatting options from EditorConfig files when parser or printer flags are not provided. source
- Distribution
- The README lists packages and installation routes including Alpine, Arch, Debian, Docker, Fedora, FreeBSD, Homebrew, MacPorts, NixOS, OpenSUSE, PyPI, Scoop, Snapcraft, Void, and webi. source
- Docker
- Docker release tags include versioned releases, a v3 stable tag, and a latest development tag; images contain shfmt and have Alpine variants. source
- Editor integrations
- Listed integrations include JetBrains shell plugins, micro, NeoVim, VS Code, Emacs, and Trunk. source
- File handling
- It can format files or standard input, recursively process directories, and list, write, or diff files whose formatting differs. source
- Formatting
- shfmt uses a consistent default style and offers flags for indentation, case indentation, binary operator placement, redirect spacing, block placement, and minification. source
- Limit
- The formatter cannot be disabled for selected line ranges, and the project says it avoids adding formatting options where possible. source
- Maintainer
- The man page identifies Daniel Martí as maintainer, assisted by open-source contributors. source
- Other integrations
- Other listed integrations include a Prettier plugin, a GitHub Action, a Markdown formatter plugin, and a pre-commit hook. source
- Purpose
- shfmt formats shell programs and is included in a shell parser, formatter, and interpreter project. source
- Security
- The latest release page says its release tag was signed with the committer’s verified signature. source
- Shell dialects
- The project supports POSIX Shell, Bash, Zsh, and mksh. source
- Support
- The project asks users to file detailed bug reports and feature requests as issues; sponsorship tiers mention prioritized issues and direct support in a company chat app. source
- Syntax checking
- The project says shfmt can replace bash -n to check scripts for syntax errors and statically parses all syntax, requiring valid UTF-8. source
Checked against the maker's pages on 9 Oct 2026.