Code · Made a little simpler

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.

Free to useNo account neededProcessed on your device
Your workspaceProcessed on your device

sh-syntax 0.8.7 runs on this device.

Add this tool to your website

Paste this code into your page to add the tool and a visible ToolMellow credit link.

HTML embed code
Preview embed

Bash Formatter: how to use it

  1. Choose Bash for scripts with Bash syntax such as arrays. Select POSIX sh for a portable shell script.
  2. Paste the complete script or load the example. Pick tabs, two spaces or four spaces and select Format shell.
  3. 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.

Tool guides