Skip to content
Toolvica

Base64 Encoder & Decoder

Encode text and files to Base64 or decode Base64 back to text and binary files. Free online Base64 tool with URL-safe mode, line length options, charset selection, file upload for encode and decode, auto-detection of PDF/PNG/ZIP and more on download.

Text to Encode
Waiting for input...0 characters
Output

Nothing to process — paste or type some input first.

Ready

Need to format, validate or convert data?

Format, validate, and minify JSON, convert between CSV and JSON formats, or convert between XML and JSON formats.

Table of Contents

How to Use the Base64 Encoder/Decoder

  1. Type or paste your text into the Encode input area to convert it to Base64. Or paste a Base64 string into the Decode input area to recover the original text.
  2. Upload a file using the Upload button on the Encode side. The tool reads it as binary and produces its Base64 representation instantly.
  3. Adjust encoding options: choose UTF-8 or ASCII character encoding, set a line length for readability, or enable URL-safe mode to replace +/ with -_.
  4. Toggle Validate before decoding to check that your Base64 string is well-formed before conversion. Invalid strings show an error message.
  5. Copy the result with one click or download it. Encoded output saves as .txt, decoded output auto-detects the file type (PDF, PNG, ZIP, etc.) and saves with the correct extension.

The Complete Guide to Base64 Encoding & Decoding

Base64 is a binary-to-text encoding scheme that converts binary data into an ASCII string format. It is widely used for embedding images in HTML, encoding email attachments, transferring binary data in JSON, and storing cryptographic keys. This tool lets you encode text and files to Base64, decode Base64 back to text or binary files, toggle URL-safe mode, choose line length and character encoding, validate before decoding, and download with automatic file-type detection for PDF, PNG, ZIP, and more.

What Is Base64?

Base64 represents binary data using 64 printable ASCII characters: A-Z, a-z, 0-9, +, and /. The = character is used for padding. It is not encryption — it is simply a way to make binary data safe for text-based channels that may not handle raw bytes correctly.

The name comes from the 64-character alphabet where each character encodes 6 bits of data. Three bytes (24 bits) become four Base64 characters, resulting in roughly 33% size increase over the original binary data.

How Base64 Encoding Works

  1. Input data is read as a stream of 8-bit bytes.
  2. Bytes are grouped into 24-bit blocks (three bytes per group).
  3. Each 24-bit block is split into four 6-bit values (0–63).
  4. Each 6-bit value maps to a character in the Base64 alphabet table.
  5. If the final block has fewer than three bytes, the output is padded with = characters to maintain the four-character alignment.

Practical Applications

Email Attachments

MIME (Multipurpose Internet Mail Extensions) uses Base64 to encode binary attachments so they travel safely through text-only SMTP email servers without corruption.

Data URLs in Web Pages

Small images and fonts can be embedded directly in HTML or CSS as Base64 data URLs, eliminating extra HTTP requests and improving page load speed on simple pages.

API Authentication Headers

HTTP Basic Authentication encodes the username:password pair as a Base64 string in the Authorization header. It is not secure on its own but works over HTTPS.

Cryptographic Key Storage

SSL certificates, SSH keys, and JWT tokens store binary cryptographic material in Base64 format so the keys can be copied, pasted, and stored as plain text.

Base64 Variants

The standard Base64 alphabet uses + and /, which have special meanings in URLs. URL-safe Base64 (RFC 4648 §5) replaces + with - and / with _, making the encoded string safe for use in query parameters and path segments without additional escaping.

MIME-style Base64 inserts a line break every 76 characters for readability in email bodies. Some implementations omit padding entirely for compactness. This tool supports all these options so you can match whatever variant your system expects.

Common Misconceptions

  • Base64 is not encryption: anyone can decode it instantly. Never use it to protect sensitive data.
  • Base64 is not compression: it increases data size by roughly 33% due to the 6-bit to 8-bit mapping overhead.
  • Base64 is not human-readable: the output looks like random characters even though it uses printable ASCII.
  • Base64 includes no error detection: a corrupted character produces garbled decoded output with no warning.

Frequently Asked Questions

Is Base64 the same as encryption?
No. Base64 is an encoding scheme, not encryption. It transforms binary data into a text-safe format but does not use any key. Anyone who receives a Base64 string can decode it immediately without special knowledge. Always use proper encryption (AES, RSA) for data confidentiality.
Why does Base64 add = padding at the end?
Padding ensures the encoded output length is a multiple of four characters. When the input data is not divisible by three bytes, one or two = characters are appended to complete the final group. Some implementations omit padding, but most decoders handle both cases.
What is the difference between Base64 and URL-safe Base64?
Standard Base64 uses + and / characters that require URL encoding (%2B and %2F) when used in URLs. URL-safe Base64 replaces them with - and _, which do not need escaping. Both decode to the same original data.
Can Base64 handle images and other binary files?
Yes. Base64 can encode any binary data: images, PDFs, audio files, executables. The tool supports file upload for encoding and can save decoded output as a binary file download.
How much larger is Base64 compared to the original data?
Base64 increases size by approximately 33%. Every three bytes of input become four ASCII characters. This overhead is the trade-off for making binary data safe to send over text-only protocols.

References

Disclaimer

This Base64 encoder and decoder is provided as a free developer utility. Base64 is an encoding scheme, not encryption — never use it to protect sensitive or confidential data. All processing happens locally in your browser. No data entered into this tool is transmitted, stored, or logged by Toolvica.