Skip to content
OddsockLocal
Local

No files yet.

Waiting for inputRuns in this browser. Nothing is uploaded.

How to use

  1. Open the image.
  2. Leave the output on the data URI for HTML or CSS.
  3. Switch to raw Base64 only if the receiver asked for the payload.
  4. Copy it. Prefer a real file URL once the image is larger than a small icon.

What is Image to Base64?

Image to Base64 writes the file’s bytes as text. The output starts as a data URI: data:image/png;base64, followed by the payload, or the matching type if you brought a JPG or a WebP. That whole string is what an img src or a CSS url() can use. Switch the output to raw Base64 when a decoder or an API asked for the payload alone. Raw text will not render if you paste it where a URI was expected.

Read more

The string is long. A 200-kilobyte PNG becomes a larger block of text, because Base64 uses about four characters for every three bytes. A photo that felt small as a file becomes an unwieldy stylesheet. Inline a tiny icon. Link a hero. A transparent PNG keeps its transparency inside the payload. You do not get a new compressed image. You get the same bytes, encoded.

The general Base64 page will encode text or any file, and it can emit Base64URL. This page is the picture, and the URI is the default because HTML is the usual destination. Nothing is uploaded to build the string. A private photo encoded into a page is still that photo, only harder to glance at.

Use cases

  • A developer inlining a 2-kilobyte PNG icon as a data URI in CSS.
  • A student pasting raw Base64 into an img src and seeing a broken image.
  • A designer watching a 200-kilobyte PNG become a much longer stylesheet rule.
  • An engineer switching to raw Base64 because an API rejected the data: prefix.
  • A teacher comparing this URI with the plain-text encoder’s handling of a sentence.

A small PNG icon as a data URI

A 32 by 32 PNG logo. Output left on data URI.

A string that starts with data:image/png;base64, and then the payload. The same file as raw Base64 omits that prefix and will not show up if it is pasted into an img src. A 200-kilobyte photo would produce a far longer line than an icon.

Why use Oddsock

Oddsock runs this in your browser. It is free, it does not upload the work, and it does not ask for an account.

Related tools

Using this tool

The data URI, including the data:image/...;base64, prefix. Raw Base64 does not.