Blob: size property
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
Note: This feature is available in Web Workers.
The size
read-only property of the Blob
interface returns
the size of the Blob
or File
in bytes.
Value
The number of bytes of data contained within the Blob
(or
Blob
-based object, such as a File
).
Examples
This example uses an <input>
element of type file
to ask
the user for a group of files, then iterates over those files outputting their names and
lengths in bytes.
HTML
html
<input type="file" id="input" multiple />
<output id="output">Choose files…</output>
JavaScript
js
const input = document.getElementById("input");
const output = document.getElementById("output");
input.addEventListener("change", (event) => {
output.innerText = "";
for (const file of event.target.files) {
output.innerText += `${file.name} has a size of ${file.size} bytes.\n`;
}
});
Result
Specifications
Specification |
---|
File API # dfn-size |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
size |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Has more compatibility info.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.