Response.prototype.blob
Takes a Response stream and reads it to completion, returning the result as a Blob
Syntax
response.blob()Return Value
A Promise that resolves to a Blob
Examples
const response = await fetch('/image.png')
const blob = await response.blob()
const url = URL.createObjectURL(blob)
console.log(url)async function downloadFile(url: string, filename: string) {
const res = await fetch(url)
const blob = await res.blob()
const a = document.createElement('a')
a.href = URL.createObjectURL(blob)
a.download = filename
a.click()
}const res = await fetch('/api/export')
const blob = await res.blob()
console.log('Size:', blob.size, 'Type:', blob.type)Understanding Response.prototype.blob
The Response.prototype.blob method in JavaScript takes a Response stream and reads it to completion, returning the result as a Blob. It belongs to the Response object and is one of the most widely used methods for working with response values in modern JavaScript and TypeScript applications.
The method signature is response.blob(). When called, it returns a promise that resolves to a blob. Understanding when and how to use blob() helps you write more expressive, readable code.
Common use cases for Response.prototype.blob include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like fetch-response-text, fetch-response-json, fetch-response-arraybuffer, enabling you to chain operations together for complex data manipulation pipelines.
Browser support for Response.prototype.blob is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.
Browser Compatibility
Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.
Related Methods
Response.prototype.textTakes a Response stream and reads it to completion, returning the result as a string
Response.prototype.jsonTakes a Response stream and reads it to completion, parsing the result as JSON
Response.prototype.arrayBufferTakes a Response stream and reads it to completion, returning the result as an ArrayBuffer
More Response Methods
Other methods in the Response object
Related Tools
More Response Methods
Explore JavaScript Methods
Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.