Your guide to what's next.
Home › Eckher Insights › What are data URLs?
Sep 26, 2021

What are data URLs?

The ins and outs of data URLs.

Data URLs are a special type of URL that, instead of pointing to an external resource available at the specified address, directly include the content of the resource within the URL string. These pseudo URLs support all content types (text, images, audio, etc.) and, like "regular" URLs, they can be linked and navigated to in the web browser.

The data URL scheme

Technically speaking, the term data URL refers to a URI that uses the data URL scheme—i.e. starts with data: and not with http:, file:, or blob:, for example. The data URL scheme is defined by RFC 2397 published in 1998, and according to that specification, a well-formed data URL always looks like this:


where the optional <mediatype> component captures the media type of the embedded content, and the presence of ;base64 indicates that the <data> part is base64-encoded. Note that the media type itself can include one or many parameters separated by semicolons, e.g. text/plain;charset=utf-8.

Examples of data URLs

Here are a few examples of data URLs:

Examples of data URLs
Data URLDerived media typeIs base64-encoded?

Generating data URLs

There are many libraries and built-in tools available for many programming languages for generating RFC 2397-compliant data URLs. If you are looking for an easy way to generate a data URL for a specific file or text string, you can use Eckher Data URI Generator.

See also
Generating data URLs in JavaScript
How to generate data URLs in JavaScript?
Your guide to what's next.
Copyright © 2022 Eckher. Various trademarks held by their respective owners.