FormatCodes
Home/Shell Tools/Shell Formatter

Shell / Bash Formatter

Format and validate Shell / Bash scripts online for free with shfmt, right in your browser.

Local browser processing
No sign-up required
Powered by shfmt
Language
Shellscript.sh
Indent
InputEditable
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
OutputShell valid31 lines · 682 B
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# Deploy script
APP_NAME="myapp"
DEPLOY_DIR="/var/www/$APP_NAME"
LOG_FILE="/var/log/$APP_NAME/deploy.log"
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" | tee -a "$LOG_FILE"
}
check_deps() {
for cmd in git docker curl; do
if ! command -v "$cmd" &>/dev/null; then
log "ERROR: $cmd is not installed"
return 1
fi
done
}
deploy() {
local branch="${1:-main}"
log "Deploying branch: $branch"
cd "$DEPLOY_DIR" || { log "ERROR: Cannot cd to $DEPLOY_DIR"; exit 1; }
git fetch origin && git checkout "$branch" && git pull origin "$branch"
docker build -t "$APP_NAME:latest" . && docker-compose up -d --remove-orphans
log "Deploy complete"
}
check_deps || exit 1
deploy "$@"
UTF-8 · Tab · shfmtLocal processing · Ready
How It WorksShell
Overview
This Shell / Bash formatter cleans up scripts with inconsistent indentation or mixed styles into a unified style, powered by a WebAssembly build of shfmt. Tab or space indent, switch-case indent, and pipe line-break options are all supported. Everything runs locally in your browser; your script never leaves your device.
Use Cases
Format Shell scripts pasted from docs or generated by AIUnify a team's CI/CD script styleClean up legacy scripts with inconsistent indentationCheck whether Shell syntax is correct
Steps
123
Paste or uploadAdjust format optionsGet the result

Related Tools

Related Guides

Frequently Asked Questions

Search Tools

Search 55+ formatting, conversion, minification, diffing, and generation tools