SVG to Base64 Converter: Encode SVG as Base64 for CSS and HTML
Convert SVG code to a Base64 string or data URI and compare the size with other encodings.
SVG to Base64 Converter tool
1Add your SVG
2Adjust the options
3Preview and download
Input and output codeView, edit and copy the code
Under the hood
How SVG to Base64 Converter works
An SVG to Base64 converter turns SVG code into a Base64 string you can embed directly in CSS, HTML or JSON. It also shows how much larger Base64 is than the original.
- SVGMinified
Minify first (optional)
If enabled, comments, metadata and whitespace are removed before encoding, which shrinks the output.
Minify pass Encode to Base64
The SVG text is converted to UTF-8 bytes and then to Base64, which uses 4 characters for every 3 bytes.
UTF-8 · btoaWrap as you need
Choose raw output, a CSS background-image rule or an <img> tag, each with the data URI prefix.
data:image/svg+xml;base64,Compare the sizes
A chart shows the SVG, URL-encoded and Base64 sizes so you can choose the smallest option.
Size comparison
What to know about Base64 SVG
- 33% overhead
- Base64 is always about a third bigger than the source.
- Not human-readable
- Unlike URL-encoded SVG, Base64 cannot be edited by eye.
- Works everywhere
- Base64 data URIs work in CSS, HTML, JSON and many tools.
Step by step
SVG to Base64 Converter process
Four steps convert an SVG to Base64. Minifying first keeps the output small.
Add your SVG
Drop a file, paste code or press the sample button.
Tip: The sample is a small icon.
Choose the wrapper
Pick Raw, CSS or <img> depending on where you will use it.
Tip: The output updates immediately.
Check the sizes
Look at the Base64 overhead tile.
Tip: Switch to URL-encoded if smaller.
BeforeAfterCopy or download
Press Copy code to put it on the clipboard, or Download to save it as a text file.
Tip: Copying from the preview gives the full output.
Reference
SVG to Base64 Converter settings / conversion chart
The table lists where each wrapper is used. The chart compares the encodings.
Relative size by encoding
At a glance
- Largest: Base64.
- Smallest: SVG source.
Base64 is about 33% larger than the source; URL-encoded is usually smaller.
| Wrapper | Looks like | Use it in |
|---|---|---|
| Raw | data:image/svg+xml;base64,… | Any URL field |
| CSS | background-image: url("…"); | Stylesheets |
| <img> | <img src="…" alt=""> | HTML pages |
| Minify first | Smaller input | All of the above |
Answers
SVG to Base64 Converter FAQ
Questions people ask about the SVG to Base64 Converter, answered for this specific use case.
Why is the Base64 output larger?
Base64 turns every 3 bytes into 4 characters, so the output is about 33% larger than the SVG.
Is Base64 the best way to embed an SVG?
URL-encoded data URIs are often smaller and compress better. Compare the sizes shown.
Can I use the output in CSS?
Yes. Choose the CSS wrapper to get a ready-to-paste background-image rule.
Does it handle non-English characters?
Yes. The SVG is encoded as UTF-8 before Base64, so special characters are preserved.
Is my SVG uploaded?
No. The encoding happens in your browser.
All converters
Every free converter and SVG tool
43 free tools that run in your browser. Pick a converter below, or search by format or task.
No converter matches that search. Try “SVG”, “logo” or “PNG”.