Blob in JavaScript
Blob in JavaScript
A Blob (Binary Large Object) is a data container that holds raw binary data — like
files, images, videos, or even text.
Think of a Blob as a chunk of data stored in memory that behaves like a file, but
lives entirely in JS.
const blob = new Blob(["Hello, world!"], { type: "text/plain" });
✅ You can:
Download it
Upload it
Preview it
Send it to a server
Convert it into a File, URL, or stream
🧱 Syntax
new Blob(arrayOfParts, options);
Parameters:
arrayOfParts: Array of strings, ArrayBuffers, or other Blobs
options.type: MIME type (like text/plain, image/png, etc.)
URL.revokeObjectURL(url); // Clean up
🔁 Read Blob Content
Option 1: FileReader
const blob = new Blob(["Hello from Blob"], { type: "text/plain" });