The WebPlatform project has been discontinued when the Stewards partnership agreement ended in September 2015. This site has been frozen, and the assets we have created will remain.


< apis‎ | file
Jump to: navigation, search


This article is Ready to Use.

W3C Working Draft


The Blob object represents immutable raw data. It provides a method to slice data objects between ranges of bytes into further chunks of raw data.


Blob provides an attribute representing the size of the chunk of data. The File object inherits from the Blob object. Blob objects can be read asynchronously only on the main thread via FileReader objects, but metadata access via attributes such as size and type return synchronously (this trade-off is based on the underlying assumption that metadata access will not significantly block or disrupt the browser's main thread, whereas reading Blob data will).


No properties.


No methods.


No events.


// Example for creating a URL to a typed array using a blob


var typedArray = GetTheTypedArraySomehow();
var blob = new Blob([typedArray], {type: "application/octet-binary"}); // pass a useful mime type here
var url = URL.createObjectURL(blob);
// url will be something like: blob:d3958f5c-0777-0845-9dcf-2cb28783acaf
// now you can use the url in any context that regular URLs can be used in, for example img.src, etc.

// Blob constructor example usage


var aFileParts = ['<a id="a">hey!</a>'];
var oMyBlob = new Blob(aFileParts, { "type" : "text/xml" }); // the blob

Related specifications

Specification Status Related Changes
W3C File API Specification W3C Working Draft

See also

Other articles

Saving files locally using Blob and msSaveBlob


This article contains content originally from external sources.

Portions of this content come from the Mozilla Developer Network cc-by-sa-small-wpd.svg: [Blob Article]

Portions of this content come from the Microsoft Developer Network: [blob constructor Article]