shfmt
What it is
shfmt is a free, open-source formatter for shell programs and part of a project that includes a shell parser and interpreter. It supports POSIX Shell, Bash, Zsh, mksh, and Bats across Linux, macOS, and Windows. A consistent default style can be adjusted with options for indentation, case indentation, binary operators, 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. It reads formatting settings from EditorConfig when parser or printer flags are absent. The project also describes syntax checking that can replace bash -n, statically parsing syntax and requiring valid UTF-8. Packages, Docker images, editor integrations, a library API, ignore files, and several automation integrations are listed.
For and against
For
- Free and open source
- Supports five listed shell languages
- Formats files, input, or directories
- EditorConfig configuration support
- Editor and automation integrations
Against
- Cannot disable formatting for selected line ranges
- Requires valid UTF-8 syntax input
- No paid support plan is listed
The verdict
shfmt provides broad shell-language formatting and syntax checking without a license cost. Its fixed formatting approach may not suit workflows needing per-line exclusions.
Who it suits
It suits shell developers and teams maintaining POSIX Shell, Bash, Zsh, mksh, or Bats code. Editor, API, and automation integrations support varied workflows.
Plans and prices
shfmt
Open-source shell formatter · no paid plan or usage limits stated
Read 9 Oct 2026 · github.com
On the record
- Configuration
- shfmt reads formatting options from EditorConfig files when parser or printer flags are not provided.github.com · read 9 Oct 2026
- 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.github.com · read 9 Oct 2026
- Docker
- Docker release tags include versioned releases, a v3 stable tag, and a latest development tag; images contain shfmt and have Alpine variants.github.com · read 9 Oct 2026
- Editor integrations
- Listed integrations include JetBrains shell plugins, micro, NeoVim, VS Code, Emacs, and Trunk.github.com · read 9 Oct 2026
- File handling
- It can format files or standard input, recursively process directories, and list, write, or diff files whose formatting differs.github.com · read 9 Oct 2026
- Formatting
- shfmt uses a consistent default style and offers flags for indentation, case indentation, binary operator placement, redirect spacing, block placement, and minification.github.com · read 9 Oct 2026
- Limit
- The formatter cannot be disabled for selected line ranges, and the project says it avoids adding formatting options where possible.github.com · read 9 Oct 2026
- Maintainer
- The man page identifies Daniel Martí as maintainer, assisted by open-source contributors.github.com · read 9 Oct 2026
- Other integrations
- Other listed integrations include a Prettier plugin, a GitHub Action, a Markdown formatter plugin, and a pre-commit hook.github.com · read 9 Oct 2026
- Purpose
- shfmt formats shell programs and is included in a shell parser, formatter, and interpreter project.github.com · read 9 Oct 2026
- Security
- The latest release page says its release tag was signed with the committer’s verified signature.github.com · read 9 Oct 2026
- Shell dialects
- The project supports POSIX Shell, Bash, Zsh, and mksh.github.com · read 9 Oct 2026
- 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.github.com · read 9 Oct 2026
- 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.github.com · read 9 Oct 2026