The URL.createObjectURL() static method creates a DOMString containing a URL representing the object given in the parameter. The URL lifetime is tied to the document in the window on which it was created. The new object URL represents the specified File object or Blob object.

Note: The use of a MediaStream object (not to be confused with MediaSource) as an input to this method is in the process of being deprecated. Discussions are ongoing about whether or not it should be removed outright. As such, you should try to avoid using this method with MediaStreams, and should use HTMLMediaElement.srcObject instead.

Note: This feature is available in Web Workers.

This feature is not available in Service Workers due to its potential to create memory leaks.


objectURL = URL.createObjectURL(object);


A File, Blob, MediaStream, or MediaSource object to create an object URL for.


See Using object URLs to display images.


Each time you call createObjectURL(), a new object URL is created, even if you've already created one for the same object. Each of these must be released by calling URL.revokeObjectURL() when you no longer need them. Browsers will release these automatically when the document is unloaded; however, for optimal performance and memory usage, if there are safe times when you can explicitly unload them, you should do so.


Specification Status Comment
File API
The definition of 'URL' in that specification.
Working Draft Initial definition.
Media Source Extensions
The definition of 'URL' in that specification.
Recommendation MediaSource extension.

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support






FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support ? ? ? ? ? ? ?

1. Supported as webkitURL.

See also