Base64 Encoder/Decoder

Input (Text or Base64)

Output

How to Use Base64 Encoder/Decoder

To Encode Text

Enter your plain text in the input field and click "Encode". The Base64 encoded string will appear in the output.

To Decode Base64

Paste a Base64 string in the input field and click "Decode". The original text will be revealed in the output.

URL-Safe Option

Enable this option if you need to use the encoded string in URLs. It replaces + and / with - and _ characters.

About Base64 Encoding

What is Base64?

Base64 is a binary-to-text encoding scheme that converts binary data into ASCII characters. It uses 64 characters (A-Z, a-z, 0-9, +, /) plus '=' for padding.

Common Uses

  • Embedding images in HTML/CSS (data URLs)
  • Sending binary data in JSON/XML
  • Email attachments (MIME)
  • Storing complex data in URLs

URL-Safe Base64

Standard Base64 uses '+' and '/' which have special meaning in URLs. URL-safe variant replaces these with '-' and '_' respectively.

Size Overhead

Base64 encoding increases data size by approximately 33%. Every 3 bytes of input becomes 4 bytes of output.

Frequently Asked Questions

What is Base64 encoding used for?

Base64 is commonly used to embed binary data in text-based formats. Key uses include embedding images in HTML/CSS as data URLs, transmitting binary data in JSON APIs, encoding email attachments (MIME), and storing binary data in databases or configuration files.

Does Base64 encrypt my data?

No, Base64 is not encryption. It's an encoding scheme that makes binary data safe for text transmission. Anyone can decode Base64 data easily. If you need security, encrypt your data before encoding it to Base64.

Why does Base64 make data larger?

Base64 increases data size by approximately 33% because it uses 4 characters to represent every 3 bytes of input. This overhead is the trade-off for being able to safely transmit binary data as text.

What is URL-safe Base64?

Standard Base64 uses + and / characters which have special meaning in URLs. URL-safe Base64 replaces these with - and _ respectively, making the encoded string safe for use in URLs and filenames.

Horizontal Banner (Responsive) 728x90 / 320x100

How to Use This Tool

  1. Enter Your Input: Paste plain text to encode or a Base64 string to decode into the input textarea. The tool automatically handles UTF-8 text, including special characters and non-ASCII content.
  2. Click Encode or Decode: Use "Encode" to convert text to Base64, or "Decode" to convert Base64 back to plain text. Invalid Base64 input during decoding will produce an error message.
  3. Copy the Result: Click "Copy" to copy the output to your clipboard. For data URLs, prepend the appropriate MIME type prefix (e.g., data:image/png;base64,) before the encoded string.
  4. Verify Round-Trip: For critical data, encode and then decode to verify the original content is preserved. This confirms proper handling of any special characters in your input.

Technical Details

Base64 encoding converts binary data to ASCII text using a 64-character alphabet (A-Z, a-z, 0-9, +, /). Every 3 bytes of input become 4 Base64 characters, explaining the 33% size increase. Padding with "=" ensures output length is always a multiple of 4 characters. The algorithm processes 24 bits at a time, splitting into four 6-bit groups mapped to the character set.

URL-safe Base64 replaces "+" with "-" and "/" with "_" to avoid URL encoding conflicts. This tool uses standard Base64 per RFC 4648. For binary files, the browser's btoa() function requires Latin-1 input, so UTF-8 text is first encoded to bytes, then Base64 encoded. Decoding reverses this: Base64 to bytes, then bytes to UTF-8 string. Maximum practical input size is limited by browser memory, typically several megabytes.

Common Mistakes to Avoid

  • Treating Base64 as Encryption: Base64 is encoding, not encryption—anyone can decode it instantly. It provides zero security. For sensitive data, encrypt first (e.g., AES), then Base64 encode the ciphertext for transmission.
  • Ignoring the 33% Size Increase: Base64 expands data by approximately 33%. A 1MB file becomes ~1.33MB when Base64 encoded. For large payloads, consider binary transfer instead of Base64-in-JSON to reduce bandwidth and parsing overhead.
  • Decoding URL-Safe as Standard: URL-safe Base64 uses "-" and "_" instead of "+" and "/". Attempting to decode URL-safe Base64 with a standard decoder may fail. Replace characters before decoding, or use a URL-safe decoder variant.

Related Tools

Need to encode special characters for URLs instead of binary data? Use our URL Encoder & Decoder for percent-encoding. For generating content hashes rather than reversible encoding, try the Hash Generator.

Frequently Asked Questions

What is Base64 encoding used for?

Base64 is commonly used to embed binary data in text-based formats. Key uses include embedding images in HTML/CSS as data URLs, transmitting binary data in JSON APIs, encoding email attachments (MIME), and storing binary data in databases or configuration files.

Does Base64 encrypt my data?

No, Base64 is not encryption. It's an encoding scheme that makes binary data safe for text transmission. Anyone can decode Base64 data easily. If you need security, encrypt your data before encoding it to Base64.

Why does Base64 make data larger?

Base64 increases data size by approximately 33% because it uses 4 characters to represent every 3 bytes of input. This overhead is the trade-off for being able to safely transmit binary data as text.

What is URL-safe Base64?

Standard Base64 uses + and / characters which have special meaning in URLs. URL-safe Base64 replaces these with - and _ respectively, making the encoded string safe for use in URLs and filenames.