Skip to main content
Calnex LogoCalnex
Conversion

Base64 Encoder / Decoder

Convert plain text to Base64 or decode Base64 back to UTF-8 text, with optional file upload producing a full data URL and raw payload.

Real-time Results

Base64 Encoded Output

SGVsbG8sIFdvcmxkISDkvaDlpb3vvIzkuJbnlYzvvIE=

How it works

This tool encodes text or an uploaded file into Base64 and decodes Base64 strings back to UTF-8 text. It also detects common image signatures in decoded payloads and offers a preview.

What happens if I paste a Base64 string that is not text?

Decoding always attempts UTF-8 text first. If the bytes are not valid UTF-8, the result shows a decoding error message instead of text. A separate image preview is added only when the string starts with a recognized signature such as iVBOR (PNG), /9j/ (JPEG), R0lG (GIF), UklGR (WebP) or PHN2Zy (SVG), or already begins with data:image/.

Does file mode accept a plain Base64 string?

File mode expects the uploaded value to be a data URL or a Base64 payload. If it contains ';base64,', only the part after that marker is used as the raw payload; otherwise the whole string is treated as the payload. The full data URL result is returned unchanged, so a value without a MIME header will not gain one.

Examples and interpretation(2)

How do I encode the short text "Hi" to Base64?

Input Type
Plain Text / Base64 String
Input Text
Hi
Conversion Mode
Encode to Base64
  1. Set Input Type to Plain Text / Base64 String, Conversion Mode to Encode to Base64, and Input Text to Hi.
  2. UTF-8 bytes 0x48 0x69 give 6-bit groups 010010 000110 1001; pad the last group to 100100.
  3. Map to S, G, k and add one '=' pad: SGk=.
Base64 Encoded Output
SGk=

The output is the Base64 Encoded Output. Padding '=' characters are part of the encoding and should be kept when decoding.

How do I decode SGk= back to text?

Input Type
Plain Text / Base64 String
Input Text
SGk=
Conversion Mode
Decode from Base64
  1. Set Input Type to Plain Text / Base64 String, Conversion Mode to Decode from Base64, and Input Text to SGk=.
  2. Map S=18, G=6, k=36; the '=' marks padding.
  3. Regroup bits 010010 000110 100100 into bytes 0x48 0x69, which is Hi in UTF-8.
Base64 Encoded Output
Hi

The Plain Text Decoded Output is Hi. Because the string is short and has no image signature, no image preview result appears.

Inputs

ParameterDefinition & Valid Bounds
Input Type

Plain Text / Base64 String · File / Image Upload

Conversion Mode

Encode to Base64 · Decode from Base64

Formula

Encode: take UTF-8 bytes, split into 6-bit groups, map each to the Base64 alphabet A–Z a–z 0–9 + /, pad with '=' to a multiple of 4. Decode: reverse the mapping and reassemble bytes, then interpret as UTF-8. File mode returns data:[mime];base64,[payload] plus the raw payload.

How to use

  1. Choose Input Type: Plain Text / Base64 String or File / Image Upload.
  2. Select Conversion Mode: Encode to Base64 or Decode from Base64.
  3. For text, type or paste into Input Text; for files, upload the file so it is read as a data URL.
  4. Run the conversion and read the Base64 Encoded Output or Plain Text Decoded Output.
  5. In file encode mode, copy either the full data URL or the raw Base64 payload.

Frequently asked questions

Why does decoding a Base64 image show an error instead of text?

Decoding first tries to interpret the bytes as UTF-8. Binary image bytes usually fail that check, so the text result reports a decoding error. The image preview result is added separately when the string matches a known image signature or starts with data:image/.

Is the raw Base64 output the same as the data URL output?

No. In file encode mode the full data URL includes the data:[mime];base64, prefix, while the raw output is only the payload after ';base64,'. Use the full URL for HTML or CSS src attributes and the raw payload when an API expects bare Base64.

Does the tool add a MIME type to a file value that lacks one?

No. File mode returns the uploaded value unchanged as the full data URL result. If the input has no MIME header, the full result will not have one either; only the raw payload is extracted.

Back to ConversionAll Calculators