Skip to content
Salyro
Tool

Image to Base64 and data URI converter

Turn an image into a data URI, base64 or the content part each provider format expects, and a data URI back into an image — in your browser.

What it does

Image → Base64: open an image and get it as a data URI, as bare base64, or as the content part each provider format carries it in:

  • OpenAI Chat Completions: image_url;
  • OpenAI Responses: input_image;
  • Anthropic Messages: an image block with a base64 source;
  • Gemini: inlineData.

Base64 → image: paste a data URI or bare base64 and see the image it holds.

Everything happens in your browser. The image is read with FileReader and never uploaded, and a pasted data URI is decoded on the page.

Try it: a PNG as an Anthropic image block, a PNG as Gemini inline data, a data URI back to an image, or base64 wrapped at 76 columns. The image is a small gradient made for the examples.

How it works

The type comes from the bytes, not from the file's name, its reported type or the type a data URI declares, since those are only what someone wrote. PNG, JPEG, GIF and WebP each start with a signature, and those four are the types Salyro's API carries. A file whose name or data URI says one type while its bytes are another is flagged, and the output uses the type the bytes are.

The content parts are written by the same code as the Request Converter. The image goes in as the first part of a user message, and the tool shows the part that format's writer produced. The tool's tests read every part back with the same parser the converter reads requests with.

Decoding a data URI follows Salyro's API exactly. The grammar is data:<type>;base64,<payload>, read by the same function the API uses. The type must be one Salyro carries. The payload must decode as base64 and encode back to itself, with no stray characters or misplaced padding. The image must be at most 15 MiB decoded. Spaces and line breaks inside the base64 are refused, as the API refuses them, and the tool offers to remove them. The preview is shown from a local object URL, released when it is replaced, and nothing pasted is ever inserted into the page as markup.

Limits

Files up to 30 MB, so that Salyro's 15 MiB limit can be shown being exceeded. Pasted text is limited to the base64 of the largest image Salyro carries. The page shows the first 4,000 characters of an output, and Copy and Download have all of it.

What it does not do

It does not resize, compress or re-encode an image. For that, use Image prep for LLMs. It does not fetch an image from a URL or send it anywhere, and a shared link holds the settings only, never the image or the data URI.

FAQ

Why is the base64 a third larger than the image?

Base64 writes every 3 bytes as 4 characters. A 15 MiB image is about 20 MiB of base64, which is why Salyro states its limit in decoded bytes.

Why was my data URI refused when it opens in a browser?

Browsers accept more than an API does: spaces, line breaks, missing padding, other parameters. The tool reads it as Salyro's API does, and says which rule it breaks.

Sources

The type signatures are those of the PNG, JPEG (JFIF), GIF and WebP (RIFF) formats. The data URI grammar, the image types and the decoded size limit are Salyro's own, from @salyro/types. The content part shapes come from the formats core's writers, which follow each provider's API reference.

Where the numbers come from

This tool works only on what you enter. It uses no external data and runs entirely in your browser.