SVG to Base64 Converter

Turn SVG markup into a Data URI for CSS backgrounds or inline HTML. Get ready-to-use snippets in four flavours: URL-encoded CSS background, Base64 CSS background, HTML img tag and raw Data URI. Live SVG preview confirms the rendering before you copy.

How to use

1

Paste your SVG code

Drop the raw SVG markup into the input field.

2

Preview the SVG

See a live preview of the rendered SVG above the output.

3

Choose a snippet

Pick CSS background (URL-encoded or Base64), HTML img, or raw Data URI.

4

Copy the snippet

Copy the ready-to-use snippet and paste it into your CSS or HTML.

Paste SVG Code
SVG preview

Ready to Use Snippets

CSS Background (URL Encoded)Optimal
CSS Background (Base64)
HTML Img Tag
Raw Base64 Data URI

Features

URL-encoded and Base64 output

Both options are provided — URL-encoding is usually smaller and compresses better.

Live SVG preview

See the SVG rendered so you can confirm it is correct before copying.

Ready-to-use snippets

CSS background, HTML img tag, and raw Data URI — copy-paste ready.

Optimal badge

Marks the URL-encoded version as optimal for size when applicable.

Common use cases

  • Embed a small icon as a CSS background
  • Inline an SVG in an HTML img tag without an extra HTTP request
  • Reduce requests by inlining SVGs in a stylesheet
  • Prepare Data URIs for build tools

Frequently Asked Questions

Related tools