Inline an SVG as a CSS background
The SVG to CSS Background Converter turns inline SVG markup into a
ready-to-paste background-image value. Inlining a small SVG as a data
URI removes an extra network request, so an icon or pattern arrives with your
stylesheet instead of loading late — perfect for icons, patterns and
decorative shapes.
Paste your <svg>…</svg> markup and you immediately get a live preview, an
optimised URL-encoded value, and a base64 fallback. Copy whichever you
need and drop it straight into your CSS.
URL-encoded is the better default
For SVG, prefer the URL-encoded output:
- It is smaller than base64, which inflates data by roughly a third.
- It stays human-readable in your stylesheet, so you can still see the shape.
- It compresses better over the wire.
The tool escapes only the characters that would break the url() token and
converts double quotes to single quotes so the whole value wraps cleanly in
double quotes. The base64 version is there for older build tooling that
mishandles unencoded data URIs.
Tips
- Keep it for small graphics — large SVGs are better left as separate files.
- The same data URI also works with
mask-imageto recolour a single-path icon viabackground-color. - If the preview is blank, confirm the SVG has a
viewBoxor explicit size and a visiblefillorstroke.
Everything runs client-side; your SVG markup is never uploaded, so it is safe for unreleased brand assets.