SVG to Base64

    Convert SVG vector code into Base64 strings and HTML data URIs for CSS background-image.

    Browser only Base64 Ready
    SVG Input
    4 lines
    1
    2
    3
    4
    Ln 1, Col 1
    242 charsUTF-8 242 B4 lines

    JsonifyTools · SVG encoder guide

    SVG to Base64 for icons, logos, and small vector assets

    Convert SVG markup or an .svg file into a Base64 string or an image/svg+xml data URI. Review the output, then copy it into a compatible HTML, CSS, or API field.

    SVG to Base64SVG Base64 encoderSVG data URIimage/svg+xmlembed SVG in HTMLCSS SVG backgroundvector icon

    Understand the output

    What does SVG to Base64 mean?

    SVG is text-based vector markup: it describes shapes, paths, colors, and other drawing instructions instead of storing a grid of pixels. An SVG to Base64 converter represents that source as an ASCII text string. The graphic remains an SVG; encoding does not turn it into a PNG, resize it, minify it, or change its vector paths.

    The standard data URI form starts with data:image/svg+xml;base64, followed by the Base64 payload. The prefix identifies the media type; the encoded characters carry the SVG text. The SVG specification registers image/svg+xml, while RFC 4648 describes Base64 encoding.

    A data URI is useful when the receiving field expects a single text value or when a small graphic needs to travel with a standalone example. It is not automatically the best delivery format: Base64 expands the input, and a separate SVG file can be easier to cache, reuse, inspect, and update.

    One graphic, two text formatsThe vector source is represented, not redrawn

    SVG source

    <svg> … paths, fills, viewBox … </svg>

    Base64 text

    PHN2ZyB4bWxu…PC9zdmc+

    Optional data URI

    data:image/svg+xml;base64,…

    A short workflow

    How to convert SVG to Base64 online

    The editor accepts source text and SVG files. Start with a known asset, then choose output settings to match the place where you will paste the result.

    01

    Paste or upload

    Paste the complete SVG markup into SVG Input, or use the upload control to open an .svg file. The sample is there if you want to inspect the format first.

    02

    Choose a variant

    Use Standard for ordinary Base64 fields. Choose URL-safe or MIME only when the receiving system specifically expects that alphabet or line wrapping.

    03

    Set the output form

    Turn on Format as Data URI when your destination needs the image/svg+xml prefix. Leave it off when a field asks for only the Base64 payload.

    04

    Encode and copy

    Select Encode Now, review the preview, then copy the result or download the text. Keep the full value, including its prefix when enabled.

    Match the receiving system

    Standard, URL-safe, and MIME Base64 for SVG

    These choices change the text representation, not the drawing. If an API or file format names a specific Base64 variant, follow that specification. Otherwise, Standard is the usual starting point for an SVG data URI.

    + /

    Standard Base64

    Uses the standard alphabet and padding. Choose it for common data URI and API examples unless the destination asks for another variant.

    - _

    URL-safe Base64

    Replaces plus and slash with hyphen and underscore. Use it only when the field or protocol requests Base64URL; it is not the default SVG data URI alphabet.

    76 characters per line

    MIME Base64

    Adds line breaks for MIME-style text. Use wrapped output only where the receiving format accepts line breaks; a continuous payload is generally more convenient in HTML and CSS.

    Quick troubleshooting

    If an SVG data URI does not render

    The encoded text can be valid while the destination rejects its format or blocks the image. Check the receiving field and browser console before changing the SVG itself.

    Check the prefix

    An HTML image source needs a complete data URI when the source is embedded. Confirm it begins with data:image/svg+xml;base64, and that the prefix appears only once.

    Copy the full payload

    A shortened preview or a pasted ellipsis is not the encoded image. Copy the full result, keep any required padding, and use the format requested by the destination.

    Review the page policy

    A site’s content security policy can block data images. Check its img-src and style-src directives when an SVG works in a local test but not in the target page.

    A real, copyable example

    SVG to Base64 example: a simple vector icon

    This source draws a green circle in a 24 by 24 viewBox. The Base64 text below is the UTF-8 SVG source encoded with the Standard alphabet; the data URI adds its media type.

    SVG input

    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10" fill="#16a34a"/></svg>

    Base64 output

    PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PGNpcmNsZSBjeD0iMTIiIGN5PSIxMiIgcj0iMTAiIGZpbGw9IiMxNmEzNGEiLz48L3N2Zz4=

    Data URI

    data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PGNpcmNsZSBjeD0iMTIiIGN5PSIxMiIgcj0iMTAiIGZpbGw9IiMxNmEzNGEiLz48L3N2Zz4=
    Use the data URI as an HTML image source
    <img src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PGNpcmNsZSBjeD0iMTIiIGN5PSIxMiIgcj0iMTAiIGZpbGw9IiMxNmEzNGEiLz48L3N2Zz4=" alt="Green circle icon" />

    Use the Base64 string alone when the receiving field asks for raw Base64. Use the complete data URI when the field expects a URL, such as an image source.

    A workflow before and after

    Share a one-file prototype without losing its icon

    A developer prepares a small HTML status-card demo for a teammate. The icon works from the developer’s project because the page points to a nearby SVG file. When the HTML is sent by itself, that relative path has no matching asset and the icon disappears.

    They convert the small SVG and set the image source to the generated data URI. Now the sample and icon can travel together in one file. That makes review or a quick reproduction easier; it does not make the encoded version smaller or improve loading speed by itself. For the finished site, the developer keeps a separate SVG so the browser can cache it and the team can update the artwork directly.

    Before · separate asset path

    <img src="./icons/status.svg" alt="Status" />

    This is clear and easy to maintain inside a project, but the SVG file must accompany the HTML.

    After · embedded SVG data URI

    <img src={statusIconDataUri} alt="Status" />

    Here, statusIconDataUri is the complete value copied from the encoder, including data:image/svg+xml;base64, when the data URI option is selected.

    Where this conversion helps

    Common SVG Base64 use cases

    This converter is for a specific handoff: turning an SVG source into text for a destination that accepts Base64 or a data URI. It does not replace an SVG editor or optimizer.

    Small CSS icons

    Set a small decorative vector as a CSS background when a stylesheet or component needs to be self-contained. Check that the page policy allows data images.

    HTML prototypes

    Use a data URI in an img source for a demo, sample page, or issue reproduction that needs to travel as one file.

    Text-only configuration fields

    Send the encoded SVG through an API or configuration field when its documentation explicitly accepts Base64 text.

    QA fixtures and examples

    Create a repeatable Base64 fixture from a known SVG for tests, documentation, or a support ticket that requires text input.

    Use an SVG data URI when

    • • The receiving API, template, or configuration field asks for Base64 or a data URI.
    • • A small icon needs to stay with a one-file example.
    • • You need a convenient text fixture to copy into documentation or QA.

    Keep a separate SVG when

    • • The artwork is reused across pages or large enough to make markup unwieldy.
    • • You want independent browser caching, direct editing, or a readable source file.
    • • You need to optimize the vector; Base64 conversion does not minify SVG paths.

    Encoding does not validate SVG content

    Base64 only changes how the source is represented as text. It does not encrypt the graphic, remove scripts, rewrite external references, or sanitize markup. For SVG received from another person or system, validate and sanitize it for the place you plan to use it. Data URI images may also be restricted by a site’s content security policy.

    Quick answers

    SVG to Base64 FAQs

    What does an SVG to Base64 converter do?

    It encodes SVG markup as Base64 text. When you add the image/svg+xml media type and the data URI prefix, the result can be used as an inline image source in compatible HTML or CSS.

    What is the difference between Base64 and an SVG data URI?

    Base64 is the encoded payload. A data URI adds a scheme and media type before that payload, for example data:image/svg+xml;base64,.... Use the format your destination expects.

    Can I convert an SVG file as well as pasted code?

    Yes. Paste SVG markup into the input editor or choose an .svg file. The result is a Base64 string, with the data URI prefix available as an option.

    Does Base64 make an SVG smaller?

    No. Base64 represents each three input bytes with four characters, so it increases the payload length by about one third before other transport compression. It is a format conversion, not an SVG optimizer.

    When should I keep a separate .svg file?

    Keep it separate when the graphic is reused, needs independent caching or editing, or is large. A data URI is most useful for a small, self-contained asset in a field that accepts it.

    Does encoding sanitize or encrypt the SVG?

    No. Base64 is not encryption and does not inspect or sanitize SVG markup. Only encode SVG you trust, and apply the validation or sanitization required by the context where you use it.