What Is a Blob URL? Why It Works in a Tab but Cannot Be Shared

Learn what a Blob URL is, why it works in a browser tab but cannot be reliably shared, and how to create, revoke, and compare it with other links.

Published
Reading time
7 min read
What Is a Blob URL? Why It Works in a Tab but Cannot Be Shared
On this page

A Blob URL can make a browser-generated file or preview available to a page without uploading it to a server. It may look like a normal link, but it refers to data managed by the browser—not a public web resource that someone else can fetch from anywhere. This guide explains how Blob URLs work, how to release them when they are no longer needed, and how they differ from data URLs and hosted download links.

Key Takeaways

  • URL.createObjectURL() creates a temporary URL that refers to a Blob or File managed by the browser.
  • A Blob URL is useful within the browser contexts allowed to access it, but it is not a dependable link to share across devices, browsers, or later sessions.
  • Keep an object URL alive while a preview or download needs it, then call URL.revokeObjectURL() when it is no longer needed.
  • A data URL puts data in the URL itself; a server-hosted link points to a resource served over HTTP or HTTPS.

What is a Blob URL?

A Blob represents immutable, file-like data. A page can create one from strings, typed arrays, or other supported data, or receive one through browser APIs such as file input. Calling URL.createObjectURL(blob) creates a string—often beginning with blob:—that the browser can use to refer to that data.

The URL is an identifier, not a copy of the data encoded as text. The browser keeps track of the association between the object URL and its underlying object. That lets browser features such as an image element, a media element, or a download link consume the data through a URL-shaped interface.

const blob = new Blob(["Hello from the browser"], {
  type: "text/plain"
});

const objectUrl = URL.createObjectURL(blob);
console.log(objectUrl); // For example: blob:https://example.com/<identifier>

The example creates an object URL; it does not upload the Blob or make it publicly available. The generated identifier is not a storage location that another computer can retrieve from a web server.

Advertisement

Why a Blob URL works in a tab but cannot be reliably shared

When a page uses a Blob URL, the browser resolves it using browser-managed state associated with the object URL. The page can pass that URL to a suitable element or API, and the browser can provide the referenced data while the URL remains usable.

That is different from sharing a normal https:// link. A server-hosted URL tells a browser where to make a network request. A Blob URL does not identify a public server holding the bytes. Copying the string to another device, browser profile, or later session does not transfer the Blob or guarantee that the receiving browser has the state needed to resolve it.

Access between browser contexts is subject to browser security rules, including origin and storage-partitioning restrictions. Some same-browser workflows may work while the creating page and object URL are still available, but that should not be treated as a portable sharing mechanism. Browser behavior around navigation and cross-context access can vary; check current documentation for the browsers you support when those details matter.

To share a file reliably, upload it to a server or file-storage service and share the resulting HTTP(S) link. The server can then apply the appropriate access controls, expiration, and availability rules.

Create and revoke an object URL

This small page creates a text file in the browser and exposes it as a download. The cleanup button revokes the object URL when the user no longer needs the link.

<a id="download-link">Download the generated file</a>
<button id="cleanup-button" type="button">Release download URL</button>

<script>
  const blob = new Blob(["Generated locally in this browser.\n"], {
    type: "text/plain;charset=utf-8"
  });

  const objectUrl = URL.createObjectURL(blob);
  const downloadLink = document.querySelector("#download-link");
  const cleanupButton = document.querySelector("#cleanup-button");

  downloadLink.href = objectUrl;
  downloadLink.download = "generated.txt";

  cleanupButton.addEventListener("click", () => {
    URL.revokeObjectURL(objectUrl);
    downloadLink.removeAttribute("href");
    cleanupButton.disabled = true;
  });
</script>

Open the page in a browser, click the download link, and then use Release download URL when you no longer need it. The example deliberately leaves cleanup under the user’s control: browsers do not provide a universal signal that a download has finished, so revoking immediately after a click can be too early for some workflows.

In a preview interface, revoke the previous URL when replacing the preview or when its owning component is removed. Keep the URL valid for as long as the browser still needs to load the resource. Calling URL.revokeObjectURL() ends the URL’s association for future use; it does not mean the browser must instantly free every related resource if something is still using it.

Lifecycle, memory, and navigation

Object URLs are temporary resources. If an application creates many of them and never releases them, their associated data may remain retained longer than necessary. The exact storage and cleanup behavior is managed by the browser; do not assume every Blob is held only in RAM or that garbage collection will release an object URL promptly.

Use these lifecycle rules:

  1. Create an object URL when you need to expose a Blob or File through a URL-based API.
  2. Keep it valid while the preview, media element, or download link needs it.
  3. Revoke it when that use is finished, such as when a preview is replaced or removed.
  4. Do not revoke a URL that another part of your interface still needs.

A Blob URL can be used for browser navigation in supported situations, but navigation does not turn it into a durable public URL. Reloading, opening it elsewhere, or navigating after its association has been revoked may fail. If an application needs a stable address that can be bookmarked or sent to another person, use a server-hosted resource instead.

Browser APIs and cross-context policies can change. This overview describes the general object-URL model, not a guarantee about every browser’s navigation or storage-partitioning behavior; verify current browser documentation for your target versions before depending on those specifics.

Advertisement

Blob URL vs. data URL vs. server-hosted download

TypeWhere the data comes fromSharing and persistenceTypical use
Blob URL (blob:)A Blob or File managed by the browserTemporary and tied to browser-managed state; not reliably portableLocal previews and generated downloads
Data URL (data:)The data is represented directly in the URLCan be copied as text, but may be unwieldy and subject to browser or application limitsSmall inline resources
Server-hosted link (https:)A server or storage service returns the resourceShareable wherever the server permits access; availability depends on that serviceShared downloads and durable links

A data URL is not a Blob URL: it carries the resource representation in the URL rather than referring to a browser-managed Blob. Data URLs can be convenient for small resources, but they are usually a poor choice for large files because the URL itself grows with the data. A server-hosted link is the appropriate option when another person or device must retrieve the resource independently.

Common Mistakes

  • Treating a Blob URL as a public link. It is not an upload, and the URL string alone does not give another device the bytes.
  • Never revoking object URLs. Clean them up when their associated preview or download workflow is finished.
  • Revoking too early. A consumer that has not loaded or started using the resource may no longer be able to access it.
  • Assuming revocation instantly frees all memory. Revocation removes the URL association; resource release is managed by the browser and depends on remaining references and use.
  • Using data URLs for large generated files. Their contents make the URL large, and they do not provide the lifecycle benefits of a Blob URL.
  • Using a Blob URL when a durable share link is required. Host the file and share its HTTP(S) address instead.

Best Practices

  • Treat object URLs as temporary browser resources, not as saved or uploaded files.
  • Store the URL only as long as the corresponding UI or browser operation needs it.
  • Pair creation with cleanup in the same component or workflow so it is easy to see who owns the URL.
  • For downloads, choose a cleanup point that does not interrupt the browser’s use of the resource; do not assume a click means the download has completed.
  • Use server storage for files that need to be shared, persisted, or retrieved by another device.
  • Test navigation and cross-context behavior in the browsers you support rather than relying on one browser’s observed behavior.

Conclusion

A Blob URL is a temporary browser-managed reference to local Blob data. It is useful for previews and generated downloads, but it is not a substitute for a shareable server URL. Keep it alive while it is needed, revoke it when its use ends, and host the resource when other people or devices must access it.

References

Current browser documentation could not be independently checked for this article. For implementation-sensitive details—especially navigation and cross-context access—consult the current documentation for the browsers and versions you support.

What would your domain sell for?

A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.