Base64 Encoder / Decoder
Encode text or files to Base64, or decode Base64 strings back to plain text. Instant results, no login required.
Base64 Tool
How to Use This Base64 Tool
Step 1: Choose your mode — click Encode to convert plain text to Base64, or Decode to convert Base64 back to readable text.
Step 2: Type or paste your input into the left text area. The conversion happens instantly as you type — no need to click a button.
Step 3: To encode a file (such as an image, PDF, or binary file), use the file upload area below the text input. The tool reads the file in your browser and produces the Base64 representation without uploading anything to a server.
Step 4: Click Copy Output to copy the result to your clipboard. Use the encoded string in your HTML data URLs, API payloads, email templates, or configuration files.
How Base64 Encoding Works
Base64 works by taking every 3 bytes (24 bits) of input and splitting them into 4 groups of 6 bits. Each 6-bit group maps to one of 64 characters (A–Z, a–z, 0–9, +, /). If the input length is not a multiple of 3, the output is padded with one or two = characters.
For example, the text "Hi" is 2 bytes (H=72, i=105). In binary: 01001000 01101001. Padded to 3 bytes: 01001000 01101001 00000000. Split into 6-bit groups: 010010 000110 100100 000000. These map to characters S, G, k, A — but with padding the result is SGk=.
What is Base64 Encoding?
Base64 is a binary-to-text encoding scheme that converts binary data into a string of ASCII characters. It uses a set of 64 characters — uppercase letters (A–Z), lowercase letters (a–z), digits (0–9), plus (+), and slash (/) — along with the equals sign (=) for padding. The result is a text-safe representation of any binary data.
Base64 encoding increases the size of data by approximately 33%. For example, a 3-byte input becomes 4 Base64 characters. Despite this overhead, Base64 is invaluable for safely transmitting binary data through text-only channels.
Common Use Cases
Email attachments (MIME): Email protocols like SMTP were designed for text. Binary attachments (images, PDFs) are Base64-encoded so they can be safely included in email messages.
Data URLs: Small images can be embedded directly in HTML or CSS using data:image/png;base64,... syntax, eliminating extra HTTP requests.
API data transfer: REST APIs often use Base64 to embed binary data (files, images) within JSON payloads, since JSON only supports text.
HTTP Basic Authentication: The Authorization header encodes the username:password string in Base64 (e.g., Authorization: Basic dXNlcjpwYXNz).
Encoding vs Encryption
Base64 is not encryption. It is a reversible encoding — anyone can decode a Base64 string without a key or password. It provides no security or confidentiality. Encryption algorithms like AES or RSA require a secret key to decrypt data. If you need to protect sensitive data, use proper encryption, not Base64.
Frequently Asked Questions
- What is Base64 encoding?
- Base64 is a binary-to-text encoding that represents binary data using 64 ASCII characters. It is used to safely transmit binary data over text-based protocols like email, HTTP, and JSON APIs.
- How do I encode a string to Base64?
- Paste your text into this tool and click Encode. In JavaScript, use
btoa()for simple strings orTextEncoder+ manual conversion for Unicode text. - How do I decode a Base64 string?
- Paste the Base64 string into this tool and click Decode. In JavaScript, use
atob()to convert Base64 back to a plain string. - Is Base64 the same as encryption?
- No. Base64 is encoding, not encryption. Anyone can decode it without a key. For security, use proper encryption algorithms like AES or RSA.
- What is Base64 used for?
- Common uses: email attachments (MIME), data URLs in HTML/CSS, binary data in JSON APIs, HTTP Basic Auth headers, and storing binary data in text-based formats like XML.