Advertisements

headerup to 320x100 / 728x90

SVG to Base64 Converter

Encode SVG vector images as Base64 data URLs so you can paste them directly into CSS background-image or HTML

SVG to Base64 Converter
Upload an SVG file and encode it as a Base64 data URL for inline CSS background-image or HTML.

Data URL prefix: data:image/svg+xml;base64,

Drop a SVG file here or pick one below.

Advertisements

content bottomup to 300x250

What is SVG to Base64 Converter

Last reviewed:

SVG is an XML-based vector graphics format that scales losslessly at any resolution. Encoding SVG as Base64 wraps the XML into a text-safe data URL so it can be embedded without a separate file.

SVG to Base64 Encoder takes a .svg file and returns a `data:image/svg+xml;base64,…` string — ideal for CSS `background-image` values that cannot reference local files.

Why use it

  • Inline small icons in CSS without shipping a separate asset.
  • Base64 encoding sidesteps escaping issues you hit with `data:image/svg+xml;utf8,…`.
  • Works in email HTML where external fetches are blocked.
  • All encoding happens in your browser.

Features

  • SVG XML encoding
  • Copy data URL or raw Base64
  • Drag-and-drop SVG upload
  • SVG markup stays on-device
  • Rendered SVG preview before copy
  • Supports .svg files

How to use SVG to Base64 Converter

  1. Drop an SVG. Drag a .svg file into the tool or click Choose SVG.
  2. Copy the data URL. Copy `data:image/svg+xml;base64,…` or just the raw Base64.
  3. Embed it. Use it as a CSS `background-image` or in an HTML `<img>` tag.

Example (before/after)

SVG file

<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><circle cx="8" cy="8" r="7" fill="#3b82f6"/></svg>

Base64 data URL

data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PGNpcmNsZSBjeD0iOCIgY3k9IjgiIHI9IjciIGZpbGw9IiMzYjgyZjYiLz48L3N2Zz4=

Common errors

Non-UTF-8 characters

Hand-edited SVG saved with a non-UTF-8 encoding will corrupt the Base64 output.

Fix: Save the SVG as UTF-8 (no BOM) and re-upload.

Larger than `utf8,…` inlining

Base64 adds ~33% overhead vs. URL-encoded SVG.

Fix: For tiny SVGs, consider the URL-encoded `data:image/svg+xml;utf8,…` form instead.

FAQ

Are scripts inside the SVG preserved?

Encoding is byte-for-byte, so embedded `<script>` blocks are preserved — but most browsers disable scripts in images loaded via `<img>` or `background-image`.

Is my file uploaded?

No. All encoding happens in your browser.

Can I decode it back to plain SVG?

Yes — use the Base64 to SVG tool to recover the XML source.

Is Base64 better than `utf8,…` for SVGs?

Base64 is more reliable when the SVG contains `#`, `<`, `>`, or quote characters that need URL escaping.

Related tools

Related encoders and vector tools: You can also browse the full Encoders & Decoders category for more options.