Bash Formatter
Format a complete Bash or POSIX shell script locally with the mvdan shell formatter. Choose a dialect and indentation, then compare the source with the formatted text.
Format a Shell Script With a Here-Document
sh-syntax 0.8.7 runs on this device.
Bash Formatter: how to use it
- Choose Bash for scripts with Bash syntax such as arrays. Select POSIX sh for a portable shell script.
- Paste the complete script or load the example. Pick tabs, two spaces or four spaces and select Format shell.
- Inspect the formatted source and any parser error. Copy or download the output as a shell file.
Limits and notes
Uses sh-syntax 0.8.7 with the mvdan parser and printer in a browser worker. Supports Bash and POSIX sh scripts up to 125,000 characters. The page parses and formats source as text.
How your privacy works →Bash Formatter: common questions
Does POSIX sh accept Bash arrays?
Array assignments such as labels=(north south) require Bash mode. POSIX sh mode reports a syntax error for them.
What happens to the lines inside a quoted here-document?
Here-document content can contain meaningful spaces and literal dollar signs. Compare the body and delimiter in the downloaded script, especially when it uses tab stripping.
Which shell should check my formatted download?
Use the parser for the script's target shell. For a trusted script you can verify syntax with bash -n, or with dash -n when it targets a POSIX shell.