Bash and Shell Script Formatter Online

Paste a bash or shell script and click Format. Powered by shfmt, runs in your browser.

How do I format a bash script online?

Paste the script, click Format, then copy the result. The formatter is shfmt compiled to WebAssembly, so it runs in your browser and produces the same layout as the shfmt command line with default settings: tab indentation, ; then and ; do on the same line as the condition, and consistent spacing. Invalid syntax returns an error with the line and column instead of broken output.

Before and after

Input

if [ -f "$1" ];then
echo "found"
for i in 1 2 3;do echo $i;done
fi

Formatted (tabs)

if [ -f "$1" ]; then
	echo "found"
	for i in 1 2 3; do echo $i; done
fi

When to use it

  • Before a commit – tidy .sh and .bash scripts so diffs show real changes
  • Pasted snippets – clean up commands copied from docs, chat or a terminal
  • CI and Dockerfile RUN blocks – normalize multi-line shell before review
  • Reading someone else's script – re-indent minified or one-line scripts

Formatting only changes layout. To catch bugs, run a linter such as ShellCheck after formatting.

Frequently asked questions

How do I format a bash script online?

Paste your script into the input box and click Format. The tool runs shfmt, the standard shell formatter, compiled to WebAssembly in your browser. It re-indents blocks, puts then and do on the right line, and normalizes spacing. Copy the result with the copy button. Nothing is uploaded.

Is this the same as shfmt online?

Yes. This page uses shfmt (mvdan/sh) compiled to WebAssembly, so the output matches running shfmt on the command line with default settings. There is nothing to install and no server round trip.

Does it use tabs or spaces?

Tabs, which is the shfmt default. The page has no indent option. If you need spaces, run the shfmt CLI locally with the -i flag, for example shfmt -i 2 -w script.sh.

Which shell syntax does it support?

Bash and POSIX sh scripts such as .sh and .bash files. Scripts for other shells that use different syntax may fail to parse.

Does the formatter check my script for bugs?

No. It only changes layout, not behavior. It will not find quoting mistakes or unset variables; use a linter such as ShellCheck for that. If the script has a syntax error, you get the line and column, for example "1:13: then must be followed by a statement list".

Is my script uploaded anywhere?

No. Formatting runs entirely in your browser, so scripts with paths, hostnames or internal commands stay on your machine.

⭐ Rate this tool

Your feedback helps us improve

Added Mar 10, 2026

🔄 Workflow Suggestion

Try combining multiple tools for a complete workflow. For example: Notepad → Text Encryption → Save to Cloud or Date Calculator → Calendar → Countdown Timer

Related Tools & Recommendations

Send Feedback

We'd love to hear your thoughts! Your feedback helps us improve our tools and create a better experience for everyone.

Share Your Experience

Tell us what you think about this tool

Your feedback helps us improve and create better tools for everyone