Convert SVG to data URI
Turns an SVG into a compact data: URL for CSS and HTML – in your browser, no upload.
Runs in your browser – your file is never uploaded
Frequently asked questions
Is my file uploaded?
No. The conversion runs entirely in your browser. The file never leaves your device – there is no server that could see it. Once the page has loaded, the tool even works offline.
Minimal or base64?
Minimal, unless a tool insists on base64. It leaves the SVG readable, collapses whitespace, swaps double quotes for single ones and only percent-encodes the characters that break a CSS url(“…”): %, #, <, > and braces. That is about a third smaller than base64, and compresses better on the wire too. Base64 is opaque but works in every context, including old e-mail clients.
How do I use the result?
In CSS: background-image: url("data:image/svg+xml,…"); or as mask-image. In HTML: <img src="data:…">. Wrap the URL in double quotes – the minimal form uses single quotes inside on purpose. The SVG to CSS tool writes a complete rule for you.
Why does the output differ from my file?
The XML prolog, comments and DOCTYPE are dropped – they mean nothing inside a data URL – and, unless you switch “Optimise first” off, the SVG is minified with the same optimiser as “Optimise SVG”. Scripts and external references are always removed.
When is a data URI a bad idea?
For large graphics. An embedded SVG is downloaded with every style sheet or page that contains it and cannot be cached on its own. Data URIs shine for small icons of a few kilobytes; for big illustrations link the file instead.
Related tools
Fix SVG viewBox
Adds a missing viewBox from width and height so the SVG finally scales – in your browser.
● In your browser
Replace colours in SVG
Swaps one colour for another throughout an SVG – fills, strokes, gradients and styles – in your browser.
● In your browser
Optimise SVG
Shrinks SVG files without changing how they look – in your browser.
● In your browser
Convert SVG to CSS background
Writes a ready-to-paste CSS rule with the SVG embedded as background or mask – in your browser.
● In your browser
QR code generator (SVG)
Turns a link or text into a scalable QR code – in your browser.
● In your browser
Placeholder image (SVG)
Makes a sized placeholder as SVG – in your browser.
● In your browser