Shfmt

It uses tabs by default, to use 4 spaces:

shfmt -i 4 script > out

shfmt formats shell programs. If the only argument is a dash (‘-‘) or no arguments are given, standard input will be used. If a given path is a directory, all shell scripts found under that directory will be used.

shfmt --help