Convert SVG code to data URIs for use in CSS background-image, HTML img tags, or inline embedding. Choose between URL-encoded (smaller) or Base64 format. Preview your SVG and copy ready-to-use code snippets.
SVG data URIs let you embed vector graphics directly in CSS or HTML without separate HTTP requests. This is especially useful for small icons, logos, and UI elements where the overhead of an HTTP request exceeds the file transfer time.
There are two encoding methods: URL-encoding (recommended for SVG) preserves readability and is typically smaller, while Base64 encoding produces a longer string but avoids potential parsing issues with special characters in some contexts.
URL-encoding is recommended for SVG. It produces smaller output (typically 20-30% smaller than Base64) and keeps the SVG partially readable. Use Base64 only if you encounter parsing issues with special characters in your specific context.
Make sure your SVG includes the xmlns attribute (xmlns='http://www.w3.org/2000/svg'). Also check that there are no unescaped special characters like # in color values, and that the SVG is well-formed XML.
There is no hard limit in modern browsers, but performance degrades with large data URIs. Keep SVG data URIs under 10KB for best results. For larger SVGs, use an external file served through a CDN.
Yes. You can store an SVG data URI in a CSS custom property (variable) and use it with url(). This is a great pattern for theming, letting you swap icons by changing a single variable value.
Encode or decode Base64 strings directly in your browser
Convert text to Base64 or decode Base64 to plain text
Convert images to Base64 encoded strings
Decode Base64 strings back to viewable images
Encode any file to a Base64 string
Decode any Base64 string back to its original file
Decode Base64 strings to PDF documents
Decode and inspect JWT tokens
Encode or decode URLs with percent-encoding
Convert special characters to HTML entities and back
Convert between hex and Base64 formats
Decode Base64 strings to plain readable text
Check if a string is valid Base64 encoding
Decode Base64 and pretty-print as formatted JSON
Generate Base64 data URIs from text or files
Convert Base64 strings to hexadecimal and back
Encode text to UTF-8 bytes or decode bytes to text