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.
Was this tool helpful?
0 people found this helpful
Nothing to process — paste or type some input first.
Was this tool helpful?
0 people found this helpful
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.
How to Use the Base64 Encoder/Decoder
- 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.
- Upload a file using the Upload button on the Encode side. The tool reads it as binary and produces its Base64 representation instantly.
- Adjust encoding options: choose UTF-8 or ASCII character encoding, set a line length for readability, or enable URL-safe mode to replace +/ with -_.
- Toggle Validate before decoding to check that your Base64 string is well-formed before conversion. Invalid strings show an error message.
- 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
- Input data is read as a stream of 8-bit bytes.
- Bytes are grouped into 24-bit blocks (three bytes per group).
- Each 24-bit block is split into four 6-bit values (0–63).
- Each 6-bit value maps to a character in the Base64 alphabet table.
- 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?
Why does Base64 add = padding at the end?
What is the difference between Base64 and URL-safe Base64?
Can Base64 handle images and other binary files?
How much larger is Base64 compared to the original data?
References
- RFC 4648 — Base16, Base32, and Base64 Data Encodings
The IETF standard defining Base64 encoding, including the standard alphabet, padding rules, and canonical encoding.
- Window.btoa() — MDN
The browser's native btoa() and atob() functions for standard Base64 encoding and decoding in JavaScript.
- RFC 4648 §5 — URL-safe Base64
URL-safe Base64 variant replacing +/ with -_ for safe embedding in URLs and filenames without escaping.
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.