JA EN

Data URL

A scheme for embedding binary data as Base64-encoded strings within URLs, commonly used to inline small images in HTML or CSS without additional HTTP requests.

A Data URL (Data URI) represents binary data as a string in the format data:[MIME type];base64,[encoded data]. It allows embedding images directly in HTML or CSS without HTTP requests, useful for small icons and placeholder images.

Base64 encoding inflates data by approximately 37%, making Data URLs inefficient for images larger than a few kilobytes. The general guideline is to limit usage to images under 2-3 KB. The Canvas API's toDataURL() method exports rendered content as a Data URL.

Compared to Blobs, Data URLs are easier to store in localStorage or embed in JSON since they are plain strings, but they are less memory-efficient. For bulk image handling, Object URLs via URL.createObjectURL offer better performance. The image compression tool may use Data URLs for quick preview rendering.

Related Terms

Related Articles