Obraz na Base64

Konwertuj obraz do ciągu Base64 do użycia w kodzie, np. tła CSS, obrazy HTML inline, e‑maile i ładunki API, a potem skopiuj go.

Encoding an image as a Base64 string

Choose an image and this tool converts it into a Base64-encoded data URL you can paste directly into CSS (background-image: url(...)), HTML (<img src="...">), or JSON payloads - useful for embedding small images without a separate file request. Everything happens locally in your browser; your image is never uploaded.

When embedding beats a separate file request

Every linked image file normally means a separate HTTP request before it can display - for very small icons or images, especially ones that appear repeatedly across a page (like a sprite or inline logo), embedding the image directly into the HTML or CSS as Base64 can eliminate that extra round trip entirely, which matters more on pages with many small images than on pages with just one or two.

Why the encoded text is roughly a third larger

Base64 represents arbitrary binary data using only 64 safe, printable characters, and that encoding scheme inherently expands the data by about 33% compared to the original binary file size - a real tradeoff against the saved HTTP request, which is why Base64 embedding makes sense for small images but becomes a net loss for larger ones.

Where embedded images commonly get used

Email templates (where external images are often blocked or stripped by email clients), small UI icons bundled directly into a CSS file, and self-contained single-file HTML documents that need to work without any external file dependencies are the most common legitimate uses for this kind of embedding.

Using the output in CSS and HTML

The result is a complete data URL, so you can drop it straight into the places that expect an image address. In a stylesheet it goes inside url() for a background-image, and in HTML it goes into the src attribute of an img tag. Either way the browser draws the picture without making a separate request, which is handy for single-file pages, HTML emails, and small interface icons that must appear instantly.

The caching trade-off to keep in mind

A linked image file is downloaded once and then reused from the browser cache on every later page. An image embedded in the HTML is downloaded again with every page view, because it is part of the document itself. Embedding in a shared stylesheet is a middle path, since the whole stylesheet is cached. For anything larger than a small icon, a normal file with long-lived caching is almost always faster.

Prepare the image before you encode it

Because Base64 makes the data about a third larger, shrink the picture first. Resize it to the exact display size, compress it with an image optimizer, and consider a modern format such as WebP when your audience's browsers support it. SVG graphics are already text, so they can usually be pasted inline without Base64 at all, and often come out smaller that way.

Najczęściej zadawane pytania

When should I use Base64 instead of a regular image file?

It is useful for small icons or images where avoiding an extra HTTP request matters, such as inline CSS or email templates. For larger images, a regular file is usually better, since Base64 encoding increases the data size by roughly 33%.

Why is the encoded text larger than my original image file?

Base64 encoding represents binary data using only text-safe characters, which adds about 33% overhead compared to the original binary file size.

Why are email templates a common use case for this?

Many email clients block or strip externally linked images by default, but an embedded Base64 image displays immediately without depending on an external request being allowed.

Is there a size limit for images I can convert?

There's no hard limit in the tool itself, but very large images produce an extremely long Base64 string that becomes impractical to embed - for anything beyond a small icon or thumbnail, a regular linked image file is the better choice.

Can I convert the Base64 string back into an actual image file?

Yes - pasting a Base64 data URL into an <img> tag's src attribute, or into a browser address bar, renders it as an image. The Base64 to Image tool on this site also decodes a pasted string straight into a downloadable file.

Does embedding an image as Base64 hurt SEO?

Search engines index images best when they are real files with descriptive names and alt text, so important content images should stay as normal linked files. Base64 embedding suits tiny decorative icons rather than images you want to appear in image search.

Which image formats can I convert?

Most formats your browser can read work, including PNG, JPEG, GIF, WebP and SVG. The encoded string keeps the image type, so it displays correctly once it is placed in your code.

Więcej w Narzędzia do obrazów