Base64 Encoder / Decoder


Text → Base64 Base64 → Text Figures out which direction automatically
{{ (data.inputText || '').length | number:0 }} chars   
{{ data.inputError }}
Auto-detected: {{ data.detectedMode === 'encode' ? 'plain text — encoded to Base64' : 'Base64 string — decoded to text' }}
{{ (data.outputText || '').length | number:0 }} chars

{{ data.fileName }} {{ data.fileSize }} • {{ data.fileType }}
{{ (data.fileBase64 || '').length | number:0 }} chars
e.g. image/png, application/pdf, text/plain
Name for the downloaded file
Tip: If you paste a full data URI (data:image/png;base64,...), MIME type is auto-filled.
{{ data.decodeError }}

Base64 Alphabet

Standard uses A–Z a–z 0–9 + / with = padding.

URL-safe replaces +- and /_, and omits padding.

Every 3 bytes of input produce 4 Base64 characters (~33% size increase).

Free Base64 Encoder and Decoder Online — Text & File Support

Our free Base64 Encoder / Decoder converts text or binary files to Base64 and back — instantly in your browser. No upload to a server, no signup, no size limits imposed by the server. Ideal for developers who need to embed images in CSS or HTML, pass binary data in JSON APIs, or inspect encoded strings during debugging.

What is Base64?

Base64 is a binary-to-text encoding scheme that represents binary data as an ASCII string using 64 printable characters (A–Z, a–z, 0–9, +, /) with = as padding. It is defined in RFC 4648. Every 3 bytes of input are encoded as 4 characters, which means Base64 output is approximately 33% larger than the original data.

Text encoding — Unicode and UTF-8

This tool fully supports Unicode text, including characters from any language, emoji, and symbols. Internally, text is first converted to UTF-8 bytes before Base64 encoding, which is the correct and portable approach. When decoding, the UTF-8 byte sequence is reconstructed from the Base64 string and then decoded back to its Unicode representation.

File encoding — embed images and binary data

Switch to File mode to upload any file and convert it to a Base64 string. This is commonly used to embed images directly in CSS (background-image: url("data:image/png;base64,...")) or HTML (<img src="data:image/jpeg;base64,...">), eliminating additional HTTP requests. You can also paste a data URI or raw Base64 string and download the decoded file.

URL-safe Base64

Standard Base64 uses + and / which are not safe in URLs and query strings. URL-safe Base64 (RFC 4648 §5) replaces + with - and / with _, and omits the = padding. It is used in JWT tokens, URL parameters, and other web contexts where the standard alphabet would require percent-encoding.

Auto-detect mode

When you select Auto-detect, the tool examines the input and decides whether it looks like a Base64 string (and should be decoded) or plain text (and should be encoded). The heuristic tries to decode the input as Base64, then checks whether the result is readable text. If both conditions pass, it decodes; otherwise it encodes. For unambiguous results, select Encode or Decode explicitly.

Frequently Asked Questions About Base64 Encoder / Decoder

Is my data sent to a server?

No. All encoding and decoding happens entirely in your browser using JavaScript. No data is transmitted to any server. You can even use the tool offline after the page has loaded.

Does this tool support Unicode and emoji?

Yes. Text is first encoded to UTF-8 bytes before Base64 encoding, so any Unicode character — including Chinese, Arabic, emoji, and mathematical symbols — is handled correctly.

What is the difference between standard and URL-safe Base64?

Standard Base64 uses the characters + and / which must be percent-encoded in URLs. URL-safe Base64 replaces + with - and / with _ and drops the = padding, making it safe to use directly in URLs, query strings, and JWT tokens without further encoding.

How do I embed an image in CSS or HTML?

Switch to File mode, upload your image, and copy the Base64 output. Then use it as a data URI: in CSS write background-image: url("data:image/png;base64,<paste here>"), or in HTML write <img src="data:image/jpeg;base64,<paste here>">.

How do I decode a Base64 file back to the original?

Switch to File mode, then choose Base64 → File. Paste your Base64 string (or a full data URI), set the MIME type and filename if needed, and click Download File. The decoded binary file is saved directly to your device.

Why does Base64 output end with = or ==?

Base64 works in 3-byte blocks. When the input length is not a multiple of 3, one or two = characters are added as padding to make the output length a multiple of 4. URL-safe Base64 omits this padding since the length can be inferred.

Why is the Base64 output ~33% larger than the input?

Every 3 bytes of binary data are represented as 4 Base64 characters. Since each character represents 6 bits (rather than 8), the encoded output is 4/3 times the original size, i.e., approximately 33% larger.

Free Base64 Encoder / Decoder Online