DataURL

Input

What is a Data URL?

A data URL (Uniform Resource Locator) is a type of URI (Uniform Resource Identifier) scheme that allows you to include data in-line in web pages as if they were external resources. Instead of referencing an external file, the data URL allows you to embed the actual data directly within the URL itself.

The general syntax of a data URL looks like this:

data:[<mediatype>][;base64],<data>

Here's a breakdown of the components:

  • <mediatype>: This is an optional parameter that specifies the MIME type of the data. For example, "text/plain", "image/jpeg", "application/pdf", etc.
  • ;base64: This is an optional parameter indicating that the data is Base64-encoded. If present, it means that the data portion is encoded in Base64 format.
  • <data>: This is the actual data that you want to include. If ;base64 is used, this data is encoded in Base64; otherwise, it is in plain text.

Data URLs are commonly used for small amounts of data, such as small images, CSS stylesheets, or even small scripts. They can be useful in situations where external file references are impractical or when you want to reduce the number of HTTP requests for external resources, potentially improving page load performance. However, they may not be suitable for large files due to increased URL length and other considerations.

Popular Utilities