Convert SVG images to Base64 data URIs for CSS backgrounds and HTML embedding. Preserves vector quality at any scale. Runs locally, no server upload.
Drag & drop files here
or click to browse. Select multiple files at once. (max 50 MB each)
SVG (Scalable Vector Graphics) is the only web image format that remains perfectly sharp at any zoom level. This tool encodes SVG files to Base64 for embedding as data URIs in CSS, HTML, or JavaScript.
SVG is unique among image formats because it is already text (XML). This creates a choice that does not exist with binary formats like PNG or JPEG: you can embed SVG as Base64, as URL encoded text, or as inline markup.
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0...);
The SVG bytes are encoded to Base64, wrapped in a data URI. The browser decodes and renders the SVG.
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' ...");
The SVG XML is percent encoded. This is typically smaller than Base64 for SVGs because SVG is already text and does not benefit from the binary to text step. The URL Encoder can help with the encoding.
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M12 2L2 22h20L12 2z"/>
</svg>
Direct markup in HTML. Most flexible: you can style it with CSS, animate it, and manipulate it with JavaScript. No encoding needed.
Despite URL encoding often being smaller, Base64 SVG data URIs are the right choice when:
Design tools export bloated SVGs. Before Base64 encoding, run the SVG through an optimizer:
npx svgo input.svg -o optimized.svg
SVGO removes editor metadata, merges paths, rounds coordinates, and strips unnecessary attributes. Typical savings: 30-60%.
<?xml ...?>). Browsers do not need it<title>, <desc>, <metadata> if not needed for accessibilityviewBox instead of width/height for scalability<defs> and gradientsModern icon systems often inline SVGs directly in HTML for styling flexibility. But for CSS only icon solutions (pseudo elements, list markers), Base64 data URIs work well:
.alert::before {
content: "";
display: inline-block;
width: 1em;
height: 1em;
background-image: url(data:image/svg+xml;base64,PHN2Zy...);
background-size: contain;
}
This approach keeps icons in CSS without touching HTML structure. Each icon is a separate data URI, typically 200-500 bytes of Base64 for simple path based icons.
| SVG content | Raw SVG | Base64 | URL encoded |
|---|---|---|---|
| Simple icon (1 path) | 200 B | 268 B | ~230 B |
| Logo (5-10 paths) | 1-3 KB | 1.3-4 KB | 1.1-3.4 KB |
| Complex illustration | 10-50 KB | 13-67 KB | 11-56 KB |
For simple SVGs, the difference between Base64 and URL encoding is small. For complex SVGs, URL encoding wins consistently. Gzip compression narrows the gap further in HTTP delivery.
For raster image encoding, see PNG to Base64, JPG to Base64, or the general Image to Base64 converter.
Nothing you paste leaves this tab. Every tool runs entirely in your browser — no upload, no server, no account.