Base64 Encoder / Decoder

Encode and decode Base64 data online

All encoding and decoding is done locally in your browser. Your data never leaves your device.

Advertisement

In-depth guide

Base64 text conversion: UTF-8, padding and URL-safe output

Encode text as Base64, interpret byte counts and understand forgiving input, UTF-8 replacement and binary-file limits.

Last verified: Markdown version (for AI)

Key figures at a glance

Text encoding
UTF-8 bytes
Byte count can differ from character count.
Padded standard length
4 × ceil(n / 3) characters
n is the number of UTF-8 input bytes; short inputs can grow by much more than one third.
URL-safe output
- and _; padding omitted
Replaces standard + and / and removes trailing =.
Decoded output
UTF-8 text
Invalid byte sequences become replacement characters; a single initial UTF-8 BOM is consumed.

Use the controls

Paste text, choose standard or URL-safe output and press Encode. The checkbox controls encoded output; decoding accepts both alphabets regardless of that checkbox. To decode, paste the Base64 payload and press Decode. Copy and Download use the output; the download is a text file.

Worked text examples

These outputs were produced by the real page buttons in a headless browser. Byte counts refer to UTF-8, not JavaScript string length.

Input Standard Base64 UTF-8 bytes
f Zg== 1
Hi SGk= 2
é w6k= 2
中 5Lit 3
அ 4K6F 3
🙂 8J+Zgg== 4

Decoding behavior

The decoder removes whitespace, maps URL-safe characters to the standard alphabet and adds missing padding where possible before calling the browser decoder. Wrapped input such as S G k= decodes to Hi. It is not a strict canonical-Base64 validator.

Decoded bytes are displayed through the browser's default UTF-8 TextDecoder. /w== contains a byte that is not valid UTF-8 and displays as �; it is not rejected as a Base64 syntax error. 77u/QQ== decodes to A because the initial UTF-8 BOM is consumed. Invalid Base64 syntax can still fail.

For the emoji example, URL-safe output is 8J-Zgg instead of 8J+Zgg==. Decode accepts either. A field expecting a different protocol may require padding or its own envelope; follow that protocol rather than assuming every receiver accepts this page's flexible input.

Files, privacy and round trips

This is a text converter, not a file uploader or a binary-file download tool. Pasting a complete data URL, MIME header or JWT is not the same as supplying its Base64 payload. Decode the relevant payload only; this page does not validate token signatures.

Conversion happens locally in the browser without uploading the text for processing. Large inputs still depend on browser memory. Base64 is reversible encoding, not encryption; possession of the encoded text is enough to decode it.

The encoder includes spaces and line breaks in text input, while a completely empty input is rejected. Text decoding can replace bytes and consume a leading BOM, so this is not a byte-for-byte archival workflow. Use image to Base64 or Base64 to image for images, and text to hex to inspect text bytes.

Advertisement

Frequently asked questions

What is Base64 encoding?

Base64 is an encoding scheme that converts binary data into ASCII text format using 64 characters (A-Z, a-z, 0-9, +, /). It's commonly used to encode binary data for transmission over text-based protocols like email or HTTP, or to embed binary data in text formats like JSON or XML. Base64 is not encryption - it can be easily decoded by anyone.

Is Base64 encoding secure?

No, Base64 is NOT secure and should never be used for security purposes. Base64 is an encoding method, not encryption. Anyone can decode a Base64 string back to the original data. It only makes data unreadable to casual observers. For actual security, use proper encryption algorithms like AES or RSA.

What is URL-safe Base64?

URL-safe Base64 is a variant that replaces + with - and / with _ in the encoded output. This makes the encoded string safe for use in URLs without additional encoding, as + and / have special meanings in URLs. It's commonly used in web tokens (JWT), URL parameters, and file names.

Why does Base64 have = padding at the end?

The = characters at the end of Base64 strings are padding to ensure the encoded string length is a multiple of 4. This is required by the Base64 specification. The number of = characters (0, 1, or 2) depends on the length of the original data. Some URL-safe Base64 implementations omit padding.

Can I encode images to Base64?

This page converts text, not uploaded image files. Use Image to Base64 to encode an image file, or Base64 to Image to recover an image. Pasting a data URL here does not make this page an image converter.

How much does Base64 increase data size?

For n UTF-8 input bytes, padded standard Base64 has 4 × ceil(n / 3) characters. The overhead approaches one third for long inputs; short inputs can grow by much more. This page omits padding in URL-safe output.

What characters are used in Base64?

Standard Base64 uses 64 characters: uppercase letters (A-Z), lowercase letters (a-z), digits (0-9), plus (+), and forward slash (/). An equals sign (=) is used for padding. URL-safe Base64 replaces + with - and / with _ to avoid conflicts with URL special characters.

Can Base64 handle Unicode and special characters?

Text is encoded as UTF-8 before Base64. Decoding displays UTF-8 text, replaces invalid byte sequences with the replacement character, and consumes a single initial UTF-8 BOM. It is not a byte-preserving binary-file decoder.

Is this Base64 tool safe for sensitive data?

Yes, from a privacy perspective. All encoding and decoding happens entirely in your browser - no data is sent to any server. However, remember that Base64 is not encryption. While your data doesn't leave your device, Base64-encoded strings can be easily decoded by anyone who obtains them.

What are common uses of Base64 encoding?

Base64 is widely used for email attachments (MIME), embedding images in HTML/CSS (data URLs), API authentication (Basic Auth), storing binary data in JSON/XML, encoding web tokens (JWT), transmitting data in URL parameters, and database storage of binary data in text columns.

Can I decode Base64 without this tool?

Yes, Base64 can be decoded using many programming languages and command-line tools. In JavaScript: atob(base64String), in Python: base64.b64decode(), in PHP: base64_decode(), in the terminal: echo "string" | base64 -d. This tool provides a convenient browser-based interface.

Why do I get an error when decoding Base64?

Malformed Base64 can fail after whitespace removal, URL-safe alphabet conversion and missing-padding restoration. This page accepts both alphabets. Invalid UTF-8 bytes are displayed with replacement characters rather than causing a Base64 decoding error.

Sources

  1. IETF — RFC 4648 Base64 and URL-safe alphabet
  2. WHATWG — Encoding: TextEncoder and TextDecoder

This guide explains published rules in plain language. It is not financial, legal or official advice — rules change, so confirm with the agency linked above before you commit.

Advertisement