What is Data URL?
Data URL is a URI scheme that allows embedding small data items inline in web documents as if they were external resources, using Base64 encoding to represent binary data directly in the URL string.
Quick Facts
| Full Name | Data URL (Data URI Scheme) |
|---|---|
| Created | 2026-02-01 |
| Specification | Official Specification |
How Data URL Works
Data URLs, also known as Data URIs, provide a way to include data in-line in web pages as if they were external resources. The scheme follows the format 'data:[<mediatype>][;base64],<data>' where mediatype specifies the MIME type and the data portion contains the actual content. For binary data like images, Base64 encoding is used to convert the binary content into ASCII characters. Data URLs eliminate the need for separate HTTP requests, reducing latency for small resources, though they increase document size due to Base64 encoding overhead (approximately 33% larger than binary).
Key Characteristics
- Format: data:[<mediatype>][;base64],<data>
- Eliminates additional HTTP requests
- Base64 encoding increases size by ~33%
- Supported in all modern browsers
- Cannot be cached separately from containing document
- Maximum length varies by browser (typically 2MB+)
- Useful for small images, fonts, and CSS backgrounds
Common Use Cases
- Embedding small images in CSS or HTML
- Inline SVG icons in stylesheets
- Single-file HTML documents
- Email HTML templates with embedded images
- Reducing HTTP requests for performance
Example
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA...