Blob: Blob() constructor

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

Note: This feature is available in Web Workers.

The Blob() constructor returns a new Blob object. The content of the blob consists of the concatenation of the values given in the parameter blobParts.

Syntax

js
new Blob(blobParts)
new Blob(blobParts, options)

Parameters

blobParts Optional

An iterable object such as an Array, having ArrayBuffers, TypedArrays, DataViews, Blobs, strings, or a mix of any of such elements, that will be put inside the Blob. Strings should be well-formed Unicode, and lone surrogates are sanitized using the same algorithm as String.prototype.toWellFormed().

options Optional

An object which may specify any of the following properties:

type Optional

The MIME type of the data that will be stored into the blob. The default value is the empty string, ("").

endings Optional

How to interpret newline characters (\n) within the contents, if the data is text. The default value, transparent, copies newline characters into the blob without changing them. To convert newlines to the host system's native convention, specify the value native.

Return value

A new Blob object containing the specified data.

Examples

js
const blobParts = ['<q id="a"><span id="b">hey!</span></q>']; // an array consisting of a single string
const blob = new Blob(blobParts, { type: "text/html" }); // the blob

Specifications

Specification
File API
# constructorBlob

Browser compatibility

desktop mobile server
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Bun
Deno
Node.js
Blob() constructor
Chrome – Full support
Chrome 20 (Release date: 2012-06-26)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 13 (Release date: 2012-06-05)
footnote
footnote Before Firefox 16, the second parameter, when set to null or undefined, leads to an error instead of being handled as an empty dictionary.
Opera – Full support
Opera 12 (Release date: 2012-06-14)
footnote Full support
Safari – Full support
Safari 6 (Release date: 2012-07-25)
footnote Full support
Chrome Android – Full support
Chrome Android 25 (Release date: 2013-02-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 14 (Release date: 2012-06-26)
footnote
footnote Before Firefox for Android 16, the second parameter, when set to null or undefined, leads to an error instead of being handled as an empty dictionary.
Opera Android – Full support
Opera Android 12 (Release date: 2012-02-25)
footnote Full support
Safari on iOS – Full support
Safari on iOS 6 (Release date: 2012-09-10)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1.5 (Release date: 2013-09-25)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote Full support
WebView on iOS – Full support
WebView on iOS 6 (Release date: 2012-09-10)
footnote Full support
Bun – Full support
Bun 1 (Release date: 2023-09-08)
footnote Full support
Deno – Full support
Deno 1 (Release date: 2020-05-13)
footnote Full support
Node.js – No support
Node.js 14.18 – 14.18 (Release date: 2021-09-28)
footnote Removed in 15 and later
Node.js – Full support
Node.js 15.7 (Release date: 2021-01-26)
footnote
footnote Before v16.7.0, the endings option was not supported.

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.
Has more compatibility info.