DataToolsLab
Code Formatter Tools

Shell Script Formatter

Normalise indentation in Bash/sh scripts and flag common shellcheck-style issues.

Loading tool…

What is Shell Formatter?

A formatter and a light linter for shell scripts. It rebuilds indentation from the block structure and points at the handful of mistakes that break real scripts.

How it works

Each line's speaker is tracked by the keywords that open and close blocks — then/do/else/case open one, fi/done/esac/} close one — and the line is re-indented to that depth. Heredoc bodies are copied verbatim. The lint pass then looks for a missing shebang, unquoted expansions, `[ … ]` where `[[ … ]]` is safer, an unguarded `cd`, and `rm -rf` on an unquoted variable.

  1. Paste the source. Drop in code, a stylesheet, a query or a selector list. Everything is read locally — the page never uploads what you paste.
  2. Choose the options. Indent width, quote style, keyword case or target browsers. The result updates as you change them, so you can see the effect immediately.
  3. Copy or download. Copy the result to the clipboard or download it as a file. Reset clears the form and returns every option to its default.

Examples

A deploy script with mixed indentation

The nested if/then/fi levels line up, so the control flow is visible again — useful before reviewing a script you inherited.

Finding the unquoted variable before it bites

`rm -rf $TARGET/tmp` is flagged as an error: with TARGET empty, that command deletes from the root, and quoting it is a one-character fix.

Common mistakes

Expecting a formatter to fix invalid code

Formatting is whitespace and quoting. A missing brace, an unclosed tag or an unquoted variable survives the round trip and is reported instead — check the findings list.

Minifying without running the tests afterwards

Even a safe, non-mangling minifier can expose an existing automatic-semicolon-insertion bug. The JavaScript Minifier keeps the newlines that matter, but re-run your tests before shipping.

Treating a rewritten query as verified

The SQL Dialect Converter translates the syntax it can prove; data types, casts and function differences are listed for review, not guessed. Run the converted query against a real database.

Renaming or reformatting generated files

Regenerating a formatter's output is a no-op only if the formatter is the same one that produced it. Keep generated code out of the round trip and format the source it came from.

Frequently asked questions

Are the lint findings shellcheck?

No. They are a small, transparent rule set for the highest-frequency mistakes — shebang, quoting, test brackets, unguarded cd, rm -rf, eval. For a full analysis, run shellcheck locally; this page is the quick pass before you commit.

Why does it not add set -euo pipefail for me?

Because that changes behaviour: a script relying on a failing command continuing will start exiting. The formatter only changes whitespace; anything semantic is left for you to decide.

Does it understand zsh or fish?

The block keywords it tracks are shared by sh, bash and zsh, so zsh scripts format fine. Fish uses different syntax (end instead of fi/done) and is not covered by this version.

Online