shfmt
shfmt is a free, open-source formatter for shell programs, included in a project that also provides a shell parser and interpreter.
What shfmt is
shfmt is a free, open-source formatter for shell programs, included in a project that also provides a shell parser and interpreter. It supports POSIX Shell, Bash, Zsh and mksh, with Bats also listed among supported languages. The tool applies a consistent default style, and flags let users adjust indentation, case indentation, binary operator placement, redirect spacing, block placement and minification. It can format files or standard input, traverse directories recursively, and list, write or diff files with formatting differences. When parser or printer flags are not supplied, it reads options from EditorConfig files. The project says shfmt can check scripts for syntax errors as an alternative to bash -n; it statically parses syntax and requires valid UTF-8. It is available for Linux, macOS and Windows, and has editor integrations, ignore-file support and a library API. The formatter cannot be turned off for selected line ranges, and the project aims to avoid adding formatting options where possible.
Good
- Supports POSIX Shell, Bash, Zsh and mksh.
- Can recursively process directories.
- Reads EditorConfig options when flags are absent.
- Includes editor integrations and a library API.
- Free and open source.
Watch out
- Cannot disable formatting for selected line ranges.
- Requires valid UTF-8 syntax input.
Who it suits
shfmt suits shell developers who want consistent formatting or syntax checks across POSIX Shell, Bash, Zsh, mksh or Bats. Editor integrations and a library API also serve users integrating it into editor or code workflows.
Verdict
shfmt offers shell formatting, syntax checking and several ways to integrate it into development workflows. Its inability to exempt selected line ranges is worth considering when formatting rules need local exceptions.
Plans and prices
From shfmt's own pricing page, checked 9 Oct 2026.
| Plan | Price | What it gives you |
|---|---|---|
| shfmt | Free | Open-source shell formatter · no paid plan or usage limits stated |
The facts
Each one read from shfmt's own pages, with the date it was checked.
What it does
- Configuration
- shfmt reads formatting options from EditorConfig files when parser or printer flags are not provided.checked 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.checked 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.checked 9 Oct 2026
- Editor integrations
- Listed integrations include JetBrains shell plugins, micro, NeoVim, VS Code, Emacs, and Trunk.checked 9 Oct 2026
- File handling
- It can format files or standard input, recursively process directories, and list, write, or diff files whose formatting differs.checked 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.checked 9 Oct 2026
- Limit
- The formatter cannot be disabled for selected line ranges, and the project says it avoids adding formatting options where possible.checked 9 Oct 2026
- Maintainer
- The man page identifies Daniel Martí as maintainer, assisted by open-source contributors.checked 9 Oct 2026
- Other integrations
- Other listed integrations include a Prettier plugin, a GitHub Action, a Markdown formatter plugin, and a pre-commit hook.checked 9 Oct 2026
- Purpose
- shfmt formats shell programs and is included in a shell parser, formatter, and interpreter project.checked 9 Oct 2026
- Security
- The latest release page says its release tag was signed with the committer’s verified signature.checked 9 Oct 2026
- Shell dialects
- The project supports POSIX Shell, Bash, Zsh, and mksh.checked 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.checked 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.checked 9 Oct 2026
Alternatives to shfmt
- 1

Prettier
Free planOpen sourceWebAPIExtensionLinux7.5Free plan - 2
Avidemux
Free planOpen sourceWebLinuxmacOSWindows7.3Free plan - 3
Fourmolu
Free planWebLinuxWindows6.7Free plan - 4
rustfmt
Free planLinuxmacOSWindows6.6Free plan - 5
Black
Free planLinuxmacOSSelf-hostedWindows6.5Free plan - 6

Ruff
Free planWebLinuxmacOSSelf-hosted6.5Free plan
