Shell Script Formatter
FormatEverything runs locally in your browser — nothing is uploaded
Tidy up a shell script that has lost its indentation: if / fi, for / done, while / do, case / esac, function bodies and subshells all line up by level, with case branch labels one level deeper and ;; returning to the branch level. The line this tool draws for itself is that it changes only the whitespace at the start of each line — not a single character inside a line. Shell is not a language you can reformat freely: everything between `<<EOF` and `EOF` is data, and one extra space changes it; continuations and newlines inside quotes depend on where they are. The cost is that it will not expand `if [ x ]; then echo ok; fi` into three lines — the benefit is that it will not break your script either.
Features
- Structural indentation: if / for / while / case / function bodies / subshells
- Case branches handled separately: labels one level deeper, ;; back to the branch level
- Only leading whitespace changes — nothing inside a line
- Heredoc bodies (<<EOF) are copied verbatim, since indenting them changes data
- Multi-line strings are left alone, and quotes inside comments are not mistaken for string starts
- Closing words followed by redirection (done < file) still line up
- Indent width of 2 or 4, with optional trailing-whitespace trim and blank-line collapsing
How to use
- Paste the script
- The indentation is fixed as you type
- Adjust the width and the two whitespace options if needed
- Copy the result
FAQ
- Why is there no "minify" option?
- Because in shell it is a trap. Comments can sit inside a heredoc, where they are data and removing them changes the output; a script without a trailing newline collapses into an unintended single line; and the newlines around && and pipes are not free to move. Most scripts would survive, but the ones that do not fail silently and behave strangely at run time — so this tool does not do it.
- Why leave heredocs untouched?
- Because every line between `<<EOF` and `EOF` is data being written; the indentation there is part of the content. Adding indentation changes what the script outputs — if it is generating YAML or a snippet of code, wrong indentation breaks the whole file. The `<<-` form allows leading tabs, but only tabs, and that distinction is preserved too.
- Does it change how the script behaves?
- No. The tool rewrites only the leading whitespace of each line, after first identifying heredocs and multi-line strings and skipping them. Everything inside a line — extra spaces, special characters, comments — is left exactly as it was.
- Is the script uploaded?
- No. Formatting happens in the browser and the page sends no requests — deployment scripts often carry keys and internal addresses, and none of it leaves the machine.
Related tools
Code Highlighter
WebColourise code and copy it with the colours intact into slides, Word or email — or export inline-styled HTML for a blog. 26 languages supported.
JS Minify & Beautify
FormatMinify JavaScript (comments and whitespace stripped, /*! licences kept) or beautify it by re-indenting on braces and semicolons. Nothing is uploaded.
SQL Formatter
FormatFormat SQL online: one clause per line, consistent keyword case, subqueries indented deeper. Minify strips comments and extra whitespace, all locally.
JSON Formatter
FormatFormat, validate and minify JSON in a collapsible tree with syntax highlighting and line numbers. Search, edit, delete or convert to Python dicts.
JSON to Code
FormatTurn JSON into TypeScript interfaces, Go structs, Java classes or Rust structs, with missing keys marked optional. Runs locally in your browser.
JSON5 Converter
FormatParse JSON5 into strict JSON: comments, unquoted keys, single quotes, trailing commas, hex and Infinity all work, with errors located by line.