.sh MIME type
Shell scripttext & code
application/x-shShell scripts. There's no registered type; application/x-sh is the usual server mapping.
| MIME type | application/x-sh |
|---|---|
| Extensions | .sh |
| Also seen as | text/x-shellscript, text/x-sh |
| Content-Type | application/x-sh; charset=utf-8 |
| Compress in transit? | Yes — enable gzip or Brotli |
Good to know
file --mime-typereports shell scripts astext/x-shellscript. Either works for downloads.- Serve install scripts as
text/plainif you want people to read them in the browser before running them —curl … | shignores the Content-Type either way. - A script needs the execute bit to run directly: chmod +x script.sh.
Serve .sh files with the right type
The response header to send:
Content-Type: application/x-sh; charset=utf-8
Most servers pick the type from the file extension. If yours sends the wrong one, map it explicitly:
nginx (inside the types block in mime.types)
application/x-sh sh;
Apache (.htaccess or server config)
AddType application/x-sh .sh
Express
res.set("Content-Type", "application/x-sh; charset=utf-8");Python
import mimetypes
mimetypes.add_type("application/x-sh", ".sh")HTML file input
<input type="file" accept=".sh,application/x-sh">
Check it
See what a server sends for a file, and what type a local file really is by its contents:
curl -sI https://example.com/file.sh | grep -i '^content-type:' file --mime-type file.sh
Frequently asked questions
What is the MIME type for .sh files?
application/x-sh. You may also see text/x-shellscript, text/x-sh, but application/x-sh is the one to send.
What Content-Type header should a .sh file be served with?
Content-Type: application/x-sh; charset=utf-8. As a text format, include the charset so browsers don't guess the encoding. It compresses well, so let the server apply gzip or Brotli.
Related types
Headers that go with it: Content-Type · Content-Disposition · X-Content-Type-Options