Shell Script Formatter

Reformat Bash, POSIX sh, and mksh scripts with consistent, canonical shell formatting. Normalize indentation, redirect spacing, and function layout while keeping your code valid. More code tools: Python Formatter | Go Formatter | C/C++/C#/Java Formatter | Code Formatter (JS/TS/PHP/TOML).
All processing happens locally in your browser — your code is never uploaded to any server.
How to use: Pick the dialect (Bash / POSIX sh / mksh), choose indentation, paste your script and click Process (or just type — auto-process on input).
Options: Tabs or 2/4 spaces; Simplify rewrites redundant constructs ($((x+0)) → $x, etc.); Space around > adds spaces next to redirection operators; Indent case bodies indents statements inside case patterns.
Dialect: Choosing the wrong dialect can change parsing — Bash scripts should stay on Bash, portable scripts on POSIX sh.
Syntax errors: Invalid scripts are reported with the exact parse error instead of being silently changed.
Privacy: The formatter runs entirely inside your browser. Nothing is ever uploaded.
Shell formatting is special

Shell is whitespace-sensitive where C-family languages are not: a heredoc’s terminator must sit alone at the start of a line unless you use <<- with real tabs, line continuations need a trailing backslash, and indentation inside strings is literal data a formatter must never touch.

<<- strips leading tab characters only — spaces before a heredoc terminator will still break the parse.