DevToolsmith

BIN MIME Type

application/octet-stream is the MIME type for arbitrary binary data, and the fallback for unknown files. Here is the Content-Type header to send, the file signature, and how to configure servers and code.

MIME type
application/octet-stream
Extensions
.bin
Content-Type header
application/octet-stream
Registered
Yes, with IANA
Compress with gzip
No, it is already compressed
Category
Programs and binaries

About Binary data files

The “I don’t know what this is” type. Browsers always download it rather than display it, so it is also used to force a download. Servers send it for any extension missing from their MIME table, which is the usual reason a .mjs, .wasm or .webmanifest file doesn’t work: add the mapping for that extension.

File signature

BIN has no fixed signature: it is data without a magic number, so validate uploads by parsing the content rather than by checking bytes.

Serve .bin with the right Content-Type

Response header
Content-Type: application/octet-stream
nginx (a line in the types { } block of mime.types)
application/octet-stream bin;
Apache (.htaccess or server config)
AddType application/octet-stream .bin
Caddy
@bin path *.bin
header @bin Content-Type "application/octet-stream"
Check what a server sends
curl -sI https://example.com/file.bin | grep -i '^content-type'
# Content-Type: application/octet-stream

Set the type in code

Node.js (Express)
res.set('Content-Type', 'application/octet-stream');
// Or make the browser download it:
res.attachment('file.bin');
Python
import mimetypes

mimetypes.add_type('application/octet-stream', '.bin')  # if your system doesn't know it
mimetypes.guess_type('file.bin')[0]  # 'application/octet-stream'
Go
mime.AddExtensionType(".bin", "application/octet-stream")
w.Header().Set("Content-Type", "application/octet-stream")

Accept .bin uploads

HTML
<input type="file" accept=".bin,application/octet-stream">

The accept attribute only filters the file picker; users can still choose another file. Listing the extension as well as the type matters, because operating systems don’t always report the type you expect.

Related types

  • .zip (application/zip): ZIP archive
  • .exe (application/vnd.microsoft.portable-executable): Windows executable
  • .wasm (application/wasm): WebAssembly module

More programs and binaries

.apk , .jar . Look up any extension or type with the MIME type lookup.

Sources

Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.

Frequently asked questions

What is the MIME type for .bin files?

application/octet-stream. The full header is "Content-Type: application/octet-stream".

Why does my server send the wrong Content-Type for .bin?

Web servers pick the type from the file extension using a table (mime.types in nginx and Apache). If .bin is missing from that table, they send a default such as application/octet-stream or text/plain. Add the mapping as shown on this page, then check the response with "curl -sI".

How can I check that a file really is BIN?

BIN has no fixed file signature, so the extension and content are all you have. Check that the content is what you expect, for example by parsing it, before trusting an upload.