Image to CSS Gradient
Turn a photo into a CSS gradient that echoes it.
Convert SVG to a CSS-safe data URI without Base64 bloat.
The encoded version, decoded and drawn
SVG to Data URI produces the CSS-safe URL-encoded form as well as Base64, and shows both sizes — URL encoding is typically 25 to 30 percent smaller and stays readable, so a colour can be changed later without re-encoding. The markup is minified first, which usually saves more than the encoding choice does.
Inlining an SVG in CSS removes a request entirely, and almost everyone does it with Base64 — which is the wrong choice.
SVG is text, so it can be URL-encoded instead, escaping only the handful of characters that would break a CSS url() value. The result is typically 25 to 30 percent smaller than Base64 and stays readable, so a colour can be changed later without re-encoding the whole thing. Both are produced here with their sizes side by side. The minifier runs first, since stripping editor metadata usually saves more than the encoding choice does.
Typically 25 to 30 percent smaller, because SVG is text and Base64 adds a third for nothing.
Fill values are still readable in the URL-encoded string, so a colour change is a find and replace.
Editor metadata is stripped before encoding, which usually saves more than either encoding choice.
The two encodings side by side, so the smaller one is obvious rather than assumed.
The encoded version is decoded and drawn, so a broken escape shows immediately.
Or load a file. It is minified first.
URL-encoded and Base64, with the size of each.
A complete background-image rule, or just the URI.
The encoded version is rendered back, so a broken escape is visible.
Because SVG is text and Base64 adds 33 percent for nothing. URL encoding only escapes the few characters CSS cannot take, and comes out 25 to 30 percent smaller.
The hash, angle brackets, quotes and percent signs at minimum. Using single quotes for attributes inside the SVG avoids escaping the double quotes around the url() value.
With URL encoding, yes — the fill values are still readable in the string, so a find and replace works. With Base64 the whole thing has to be re-encoded.
No hard limit, but past a few kilobytes a separate cached file is better. Inlining is for small icons and patterns.
What people who use the SVG to Data URI think of it. Reviews come from visitors and are posted as written.
No ratings yet
Yours would be the first.
0 reviews
Newest first
No reviews yet
Be the first to rate the SVG to Data URI. It takes half a minute and no account.
Write the first reviewTurn a photo into a CSS gradient that echoes it.
Put a coloured border or frame around any photo.
Make a multi-size .ico file from any image.
Map an image onto two colours for a bold graphic look.
Design a 1200 by 630 social preview card.
Add whitespace around an image without cropping anything.
Shrink JPEG, PNG and WebP files without uploading them anywhere.
Every current image size for every major platform.