Skip to content

application/wasm MIME Type — Meaning, Usage & Examples

application/wasm
Extensions: .wasm Class: application Spec: W3C (IANA registered)
View IANA registration ↗

application/wasm means: application/wasm is the registered media type for WebAssembly binary modules, a portable low-level bytecode that runs in browsers and runtimes at near-native speed. The type lets fetch-based instantiation and streaming compilation recognize the payload as a wasm module. Application media types carry structured or binary data that a program consumes rather than a human reading raw bytes. The subtype tells the receiver exactly which parser, decoder or handler to invoke, so sending the correct Content-Type is part of the API contract: a mismatch makes servers reject the body with 415 Unsupported Media Type or clients mis-parse the payload. You will encounter application/wasm in contexts such as webassembly modules compiled from rust, c/c++ or go for the browser; streaming compilation via webassembly.instantiatestreaming(fetch(...)); edge and serverless runtimes executing portable wasm binaries. It is commonly associated with the file extension(s) .wasm. instantiateStreaming requires the response Content-Type to be exactly application/wasm; a wrong type forces a slower ArrayBuffer fallback or throws. Serve wasm with the correct type and enable compression and caching for large modules.

Advertisement
Ad slot · ref-top

When you'll see application/wasm

  • WebAssembly modules compiled from Rust, C/C++ or Go for the browser
  • Streaming compilation via WebAssembly.instantiateStreaming(fetch(...))
  • Edge and serverless runtimes executing portable wasm binaries

How to handle it

When handling an application type, set the Content-Type header explicitly on every request and response that carries a body, and advertise what you accept with the Accept header. Parse the payload with a library that matches the subtype rather than sniffing bytes, and validate the structure before trusting it. If a server returns 415, the declared type does not match what it expects — compare your header against the API documentation character for character, including parameters such as charset or boundary. As a final checklist for application types: register the exact subtype in your API documentation, validate incoming bodies against a schema before use, set X-Content-Type-Options: nosniff to stop MIME sniffing, and version your media types when the payload contract changes so old clients keep working.

Notes & gotchas

instantiateStreaming requires the response Content-Type to be exactly application/wasm; a wrong type forces a slower ArrayBuffer fallback or throws. Serve wasm with the correct type and enable compression and caching for large modules.

Examples

HTTP
HTTP/1.1 200 OK
Content-Type: application/wasm
Content-Length: 79

Sample application/wasm content delivered with the correct Content-Type header.
curl
curl -i -H "Accept: application/wasm" https://api.example.com/v1/resource   # inspect the returned Content-Type
JavaScript (fetch)
// instantiateStreaming requires Content-Type: application/wasm exactly.
const { instance } = await WebAssembly.instantiateStreaming(
  fetch("/module.wasm"), importObject
);
Python (requests)
import requests

res = requests.get("https://api.example.com/v1/resource",
                   headers={"Accept": "application/wasm"}, timeout=10)
res.raise_for_status()
# confirm the server declared the expected type
assert res.headers["Content-Type"].startswith("application/wasm")
text = res.text   # decode/handle according to the type

Frequently asked questions

Why does instantiateStreaming reject my wasm file?

Because the server did not return application/wasm. The streaming API checks the MIME type and refuses non-wasm responses; fix the header or fall back to instantiating from an ArrayBuffer.

Can wasm be gzipped?

Yes — serve it with Content-Encoding: gzip or brotli alongside Content-Type: application/wasm. Browsers decompress transparently, cutting transfer size for large modules.

What happens if I send the wrong application Content-Type?

Servers that validate media types answer 415 Unsupported Media Type, and clients may parse the body with the wrong decoder. Always set Content-Type to the registered type that matches your payload, and set Accept to the types you can handle.

Is application/octet-stream a safe default?

It means 'arbitrary binary bytes' and forces a download rather than inline handling. Use it only when the real type is unknown or you deliberately want a save-as dialog; otherwise declare the specific registered type.

How do I debug a 415 Unsupported Media Type response?

Compare the Content-Type you actually sent against what the endpoint documents, including parameters like charset and boundary. A 415 means the server refuses that media type; send the exact registered type it accepts and retry.

Advertisement
Ad slot · ref-in-article

Try the JSON Formatter

Beautify, validate and minify JSON with clear error messages.

Open tool →