Blob: type property

Note: This feature is available in Web Workers.

The type read-only property of the Blob interface returns the MIME type of the file.

Note: Based on the current implementation, browsers won't actually read the bytestream of a file to determine its media type. It is assumed based on the file extension; a PNG image file renamed to .txt would give "text/plain" and not "image/png". Moreover, blob.type is generally reliable only for common file types like images, HTML documents, audio and video. Uncommon file extensions would return an empty string. Client configuration (for instance, the Windows Registry) may result in unexpected values even for common types. Developers are advised not to rely on this property as a sole validation scheme.


A string containing the file's MIME type, or an empty string if the type could not be determined.


This example asks the user to select a number of files, then checks each file to make sure it's one of a given set of image file types.


<input type="file" id="input" multiple />
<output id="output">Choose image files…</output>


// Our application only allows GIF, PNG, and JPEG images
const allowedFileTypes = ["image/png", "image/jpeg", "image/gif"];

const input = document.getElementById("input");
const output = document.getElementById("output");

input.addEventListener("change", (event) => {
  const files =;

  if (files.length === 0) {
    output.innerText = "Choose image files…";

  const allAllowed = Array.from(files).every((file) =>
  output.innerText = allAllowed
    ? "All files clear!"
    : "Please choose image files only.";



File API
# dfn-type

Browser compatibility

BCD tables only load in the browser

See also