EN
PortuguêsEnglishEspañol
All tools
Developer tools 100% free

SVG to data URI (CSS and HTML)

Convert SVG code into an optimized data URI for use in CSS (background-image, mask) and HTML, with URL encoding that is shorter than Base64 and an image preview.

How to use

Thank you so much for helping!

Every donation helps pay for the servers and keeps the tools free for everyone. Pick or type an amount:

Secure payment by Stripe. Opens in a new tab.

Back to CSS and design

Paste the SVG code.

Available in: PortuguêsEspañolEnglish

Advertisement

SVG to data URI (CSS and HTML): what it is for

Paste the SVG code and choose the output format. The tool removes extra whitespace, swaps quotes and encodes only the characters that need it, producing a data URI smaller than Base64, and shows a preview of the image and the final size.

The code is not sent to any server: the conversion happens in your browser.

How to use

  1. Paste the SVG code.
  2. Choose CSS, data URI, img or Base64.
  3. Copy the result.

When to use it

  • Embedding icons in CSS without extra files.
  • Using SVG in mask-image.
  • Reducing page requests.

Frequently asked questions

Why not use Base64?

For SVG, URL encoding usually produces a smaller result than Base64, because SVG is already text. Only special characters, such as <, >, # and quotes, need to be encoded.

How do I use it in CSS?

Copy the result in the background-image: url("data:image/svg+xml,...") format. It also works in mask-image, list-style-image and the src attribute of an img tag.

Is it really free?

Yes, 100% free. No sign-up, no subscription and no usage limits. All Tools123 tools are free and run right in your browser.

Similar tools

The tools are provided as is, without warranty. We are not responsible for the results or for how they are used.