🔤 Base64 Encoder/Decoder - Encode and decode Base64

🔧 Operation

⚙️ Options

Variant

Decoding detects the alphabet automatically and restores missing padding.

📝 Input Text

📤 Output

{{ detectedNote }}

⚠️ {{ error }}

ℹ️ About Base64 Encoding

Base64 is a binary-to-text encoding defined by RFC 4648. It represents arbitrary bytes with 64 printable US-ASCII characters (A-Z, a-z, 0-9, +, /) so binary data can travel through systems that expect text: the encoder takes 3 input bytes (24 bits) at a time and emits 4 characters, so output is about one third larger than the input, and = padding completes the final block when the input length is not a multiple of 3. Base64 is reversible encoding, not encryption or compression.

This tool encodes UTF-8 text to Base64 and decodes Base64 back to text, in the standard alphabet (RFC 4648 section 4) or the URL-safe Base64URL alphabet (section 5). Typical uses are embedding bytes in JSON, XML, YAML and logs, MIME bodies and attachments, data: URLs such as data:text/plain;base64,SGVsbG8=, HTTP Basic authentication credentials, and JWT or JWS segments; the RFC for each is listed under References.

Supported inputs

  • Encode: any Unicode text. It is converted to UTF-8 bytes first, so accented characters and emoji round-trip correctly.
  • Variant: Standard (RFC 4648 section 4) or URL-safe (RFC 4648 section 5), chosen with the Variant buttons or the API field variant (standard or url-safe).
  • Padding: trailing = is emitted by default. The "Omit = padding" checkbox or the API field "padding": false strips it, which is what JWT segments and most URL tokens expect.
  • Decode: standard or URL-safe Base64, with complete padding or none at all (partial padding is rejected). ASCII whitespace (spaces, tabs, line breaks) is removed first, so MIME-wrapped input decodes without editing. The alphabet is detected automatically; input that mixes +// with -/_ is rejected.

Output

Encoding returns the Base64 string in the selected variant. Decoding returns the original text and shows a note under the output with the detected alphabet (standard, URL-safe, or that no alphabet-specific character occurs; the API reports that case as ambiguous), whether missing padding was restored, and the decoded byte count. The API returns result together with variant and padded: on encode they echo the requested options, on decode they report what was detected.

Example

hello encodes to aGVsbG8=, and decoding U3RhbmRhcmQtQmFzZTY0 returns Standard-Base64. The four bytes ???> (3F 3F 3F 3E) show the variants side by side: Pz8/Pg== in standard Base64, Pz8_Pg== in URL-safe Base64, and Pz8_Pg with padding omitted. All three decode back to ???>.

Limitations

  • Text only: decoded bytes are interpreted as UTF-8, and input that is not valid UTF-8 is reported as an error rather than shown as garbled text. Use the Base64 File Encoder or Base64 Image Encoder for binary data.
  • The decoder does not check that unused trailing bits are zero, so non-canonical encodings decode instead of being rejected; neither this page nor the API offers a strict RFC 4648 validation mode.
  • Decoding does not split data: URLs or HTTP Authorization: Basic headers. Paste only the Base64 part after the comma or after the Basic keyword.
  • Input is processed on every keystroke in a single pass, so very large strings (many megabytes) can make the page slow.

Browser or server processing

The interactive tool runs in the browser through the shared logic module; nothing you type here leaves your device. The public API runs the same module on the server, so only the API path sends text to the server. Avoid sending passwords, private keys or access tokens through the API unless you are comfortable with that processing path.

FAQ

Why does this Base64 string fail to decode?

The decoder rejects characters outside the two alphabets, a length that leaves a remainder of 1 when divided by 4, = anywhere except the end, a number of trailing = that does not match the length (leaving padding out entirely is fine, partial or excess padding is not), and input that mixes +// with -/_. A separate error appears when the bytes decode but are not valid UTF-8 text, which usually means the input is a binary file rather than text.

What is the difference between Base64 and Base64URL?

Base64URL (RFC 4648 section 5) swaps + for - and / for _ so the result fits in URLs, filenames and JWT segments without percent-encoding, and it usually omits = padding. The other 62 characters and the bytes they represent are identical. Choose URL-safe under Variant to produce it; decoding recognises it automatically. To inspect a whole token, use the JWT Decoder.

Is Base64 encryption?

No. Base64 has no key, so anyone can decode it; use real encryption when confidentiality matters and Base64 only to carry the ciphertext through text-only channels.

Can I encode a file or image?

This page works on UTF-8 text. For arbitrary files, including decoding Base64 back to a downloadable file, use the Base64 File Encoder; for images and CSS or HTML data URIs, use the Base64 Image Encoder.

References

API Usage Example:

POST /api/tools/encoding-decoding/base64
Content-Type: application/json

{
    "text": "hello",
    "operation": "encode",
    "variant": "url-safe",
    "padding": true
}
Ready