How to Use This Base64 Encode / Decode Tool
1
Choose Mode — Encode or Decode
Click 🔒 Encode to convert plain text to Base64, or 🔓 Decode to convert Base64 back to plain text. Use Encode when you want to represent binary or text data in Base64 format. Use Decode when you have a Base64 string and want to see the original content.
2
Set Options (Optional)
URL-Safe: Enable this when encoding data that will be used in URLs or HTTP headers. It replaces + with - and / with _ to avoid URL encoding conflicts. Live Mode: Auto-processes as you type. Remove Whitespace: Strips extra spaces/newlines from input before processing.
3
Type or Paste Your Input
Type or paste your text into the input box. With Live Mode on, the result appears instantly. With Live Mode off, click the button to process. The tool automatically shows character count and byte count for both input and output.
4
Click Encode / Decode
Click the blue button to process. The result appears in the output box below. Stats show output character count, byte size, and the size increase percentage (encoding always increases size by ~33%).
5
Copy Result or Send to Other Mode
Click 📋 Copy Result to copy the output to your clipboard. Or click 🔄 Send to Decoder/Encoder to automatically switch modes and send the output as input for the next operation.
What is Base64 Encoding? — Complete Guide
Base64 is a binary-to-text encoding scheme that converts binary data into a sequence of printable ASCII characters. The name "Base64" comes from the fact that it uses 64 different characters to represent data: A-Z (26), a-z (26), 0-9 (10), + and / (2) = 64 total, plus = for padding.
Base64 was invented in the 1980s primarily for email attachments (MIME encoding) because email systems could only reliably transmit 7-bit ASCII text — not raw binary data. By encoding binary data as Base64 text, files like images, PDFs, and executables could be safely transmitted as email attachments. Today, Base64 is used everywhere in web development, APIs, and data transfer.
🔑 Key Point: Base64 is encoding, not encryption. Anyone can decode a Base64 string without any key. It provides no security — only compatibility for transmitting data in text-based systems. Never use Base64 to protect sensitive passwords or private data.
How Does Base64 Encoding Work?
Base64 converts data by taking 3 bytes (24 bits) at a time and splitting them into 4 groups of 6 bits each. Each 6-bit group (values 0–63) is then mapped to one of the 64 Base64 characters.
🔬 Step-by-Step Example: Encoding "Hi"
Input: H i
ASCII: 72 105
Binary: 01001000 01101001
Group into 6-bit chunks: 010010 | 000110 | 1001 (pad with 00) = 010010 000110 100100
Decimal: 18, 6, 36
Base64 chars: S, G, k, = (padding)
Result: SGk=
The = padding at the end is added when the input length is not a multiple of 3. One = means 1 byte of padding was added; == means 2 bytes were padded. The decoder uses this to know how many actual bytes to return.
Base64 Character Table
Base64 uses exactly 64 characters plus the = padding character. Here is the complete character mapping:
| Value | Char | Value | Char | Value | Char | Value | Char |
| 0 | A | 16 | Q | 32 | g | 48 | w |
| 1 | B | 17 | R | 33 | h | 49 | x |
| 2 | C | 18 | S | 34 | i | 50 | y |
| 3 | D | 19 | T | 35 | j | 51 | z |
| 4 | E | 20 | U | 36 | k | 52 | 0 |
| 5 | F | 21 | V | 37 | l | 53 | 1 |
| 6 | G | 22 | W | 38 | m | 54 | 2 |
| 7 | H | 23 | X | 39 | n | 55 | 3 |
| 8 | I | 24 | Y | 40 | o | 56 | 4 |
| 9 | J | 25 | Z | 41 | p | 57 | 5 |
| 10 | K | 26 | a | 42 | q | 58 | 6 |
| 11 | L | 27 | b | 43 | r | 59 | 7 |
| 12 | M | 28 | c | 44 | s | 60 | 8 |
| 13 | N | 29 | d | 45 | t | 61 | 9 |
| 14 | O | 30 | e | 46 | u | 62 | + |
| 15 | P | 31 | f | 47 | v | 63 | / |
URL-safe Base64 replaces value 62 (+) with - (hyphen) and value 63 (/) with _ (underscore), and omits = padding.
Common Use Cases of Base64 Encoding
🌐
HTTP & API Authentication
HTTP Basic Authentication encodes credentials as Base64. The header looks like: Authorization: Basic dXNlcjpwYXNz where the value is Base64(username:password). Note: this is NOT secure without HTTPS — Base64 is easily decoded.
🖼️
Embed Images in HTML/CSS
Images can be embedded directly in HTML or CSS as Base64 data URIs: src="data:image/png;base64,iVBORw0...". This eliminates an extra HTTP request for small icons. Used in email templates where external images may be blocked.
📧
Email Attachments (MIME)
Email protocols (SMTP) are text-based. File attachments (PDFs, images, Office files) are Base64-encoded in MIME format to be safely transmitted through email servers that can only handle 7-bit ASCII text.
🔑
JWT Tokens
JSON Web Tokens (JWT) use URL-safe Base64 encoding for their header and payload sections. A JWT looks like: xxxxx.yyyyy.zzzzz where each section is Base64-encoded JSON. Decode the payload section with this tool to see the claims.
💾
Store binary data (certificates, keys, files) in JSON or XML which only support text. SSL/TLS certificates (PEM format) are Base64-encoded with -----BEGIN CERTIFICATE----- headers.
JSON & XML Data Storage
🔐
Cryptography Output
Encryption outputs (AES, RSA), digital signatures, and hash values are binary. They are Base64-encoded for storage and transmission in text fields (databases, config files, APIs). The output of most encryption libraries is Base64.
Base64 Encode / Decode Examples
| Original Text | Base64 Encoded | Length Increase |
| Hello | SGVsbG8= | 5 → 8 chars (+60%) |
| Hello World | SGVsbG8gV29ybGQ= | 11 → 16 chars (+45%) |
| {"name":"Raj"} | eyJuYW1lIjoiUmFqIn0= | 14 → 20 chars (+43%) |
| user:password123 | dXNlcjpwYXNzd29yZDEyMw== | 16 → 24 chars (+50%) |
| https://example.com | aHR0cHM6Ly9leGFtcGxlLmNvbQ== | 19 → 28 chars (+47%) |
| नमस्ते (Hindi) | 4KuH4Kqo4Kqr4Kqk4Kq+ | Unicode multi-byte |
Base64 vs Other Encodings
| Encoding | Characters Used | Size Overhead | Use Case |
| Base64 | A-Z, a-z, 0-9, +, / | ~33% | General binary-to-text, emails, APIs |
| Base64 URL-safe | A-Z, a-z, 0-9, -, _ | ~33% | URLs, JWT, filenames |
| Base32 | A-Z, 2-7 | ~60% | Case-insensitive systems, TOTP 2FA |
| Base16 / Hex | 0-9, A-F | 100% | Hash values, colors, binary debug |
| URL encoding (%) | %, 0-9, A-F | Varies | Special chars in URLs |
| HTML entities | &, #, ; etc | Varies | Special chars in HTML |
Frequently Asked Questions (FAQ)
What is Base64 encoding and why is it used? ▼
Base64 is a binary-to-text encoding scheme that converts binary data into a sequence of 64 printable ASCII characters (A-Z, a-z, 0-9, +, /). It was invented to solve a fundamental problem: many text-based systems like email (SMTP), HTTP headers, and XML can only reliably handle plain ASCII text — they cannot handle raw binary data (which can contain non-printable characters and control codes). By encoding binary data as Base64 text, it can be safely transmitted through any text-based system without corruption. Common uses: email attachments (MIME), HTTP Basic Authentication, JWT tokens, embedding images in HTML, and storing binary data in JSON/XML.
Is Base64 the same as encryption? Is it secure? ▼
No — Base64 is encoding, not encryption. This is one of the most common misconceptions in programming. Encoding is a reversible transformation using a publicly known algorithm — anyone can decode a Base64 string without any secret key, using this tool or a one-line command. Encryption, on the other hand, requires a secret key to decrypt and is designed to keep data confidential. Never use Base64 to protect sensitive data like passwords, API keys, or personal information. A hacker who sees your Base64-encoded "password" has your password — it takes 1 second to decode. Use proper encryption (AES-256, RSA) for security.
Why does Base64 end with == or = signs? ▼
The = signs are padding characters. Base64 works by processing input in groups of 3 bytes (24 bits), converting them to 4 Base64 characters. If the input length is not divisible by 3, padding is added: One = means the last group had only 2 bytes (1 byte of padding added). Two == means the last group had only 1 byte (2 bytes of padding added). No padding means the input was exactly divisible by 3. Decoders use this padding to know how many actual data bytes the last group contains. URL-safe Base64 often omits padding to avoid the = sign having special meaning in URLs.
What is URL-safe Base64 and when should I use it? ▼
Standard Base64 uses + (plus) and / (slash) characters which have special meanings in URLs — + means space, / means path separator. When Base64-encoded data is used in a URL (as a query parameter, path segment, or cookie), these characters must be percent-encoded (%2B for + and %2F for /), which makes the URL ugly and longer. URL-safe Base64 (RFC 4648) solves this by replacing + with - (hyphen) and / with _ (underscore), which are both URL-safe characters. Use URL-safe Base64 when: building JWT tokens, creating safe filenames, encoding data for URL query parameters, or any web context where the encoded string will appear in a URL. Enable the "URL-Safe" toggle in this tool to use this format.
Why is my Base64 decode showing an error? ▼
Common reasons for Base64 decode errors: 1. Missing or extra padding: The string must have = padding to make its length a multiple of 4. If the string length is not divisible by 4, add = signs at the end until it is. 2. URL-safe vs standard: If the string contains - or _ characters, it is URL-safe Base64. Enable the URL-Safe option and try again. 3. Whitespace: Spaces, newlines, or tabs in the string cause errors. Enable "Remove Whitespace" option. 4. Not actually Base64: The string may be hex (0-9, A-F only), regular text, or another encoding entirely. 5. Truncated string: Make sure you copied the complete Base64 string, including all trailing = characters.
How do I encode/decode Base64 in programming languages? ▼
Every major programming language has built-in Base64 support:
JavaScript: btoa("Hello") → encode, atob("SGVsbG8=") → decode
PHP: base64_encode("Hello") → encode, base64_decode("SGVsbG8=") → decode
Python: import base64; base64.b64encode(b"Hello") → encode, base64.b64decode("SGVsbG8=") → decode
Java: Base64.getEncoder().encodeToString("Hello".getBytes())
Linux terminal: echo -n "Hello" | base64 → encode, echo "SGVsbG8=" | base64 -d → decode
For Unicode/multi-byte strings in JavaScript, use btoa(unescape(encodeURIComponent(str))) to handle non-ASCII characters correctly.
How much does Base64 increase the size of data? ▼
Base64 encoding increases data size by approximately 33–36%. The exact formula: 3 bytes of input → 4 bytes of Base64 output = 33% increase. With padding, the overhead can be slightly higher. Examples: A 1 KB file becomes ~1.37 KB in Base64. A 100 KB image becomes ~137 KB. A 1 MB PDF becomes ~1.37 MB. This size increase is a trade-off for compatibility — the encoded data can now be transmitted safely through any text-based system. For large files, consider compressing (gzip/deflate) before encoding to partially offset the size increase. Base64-encoded images in HTML/CSS increase page size and should only be used for small icons and logos.
How can I decode a JWT token using this tool? ▼
A JWT (JSON Web Token) has three parts separated by dots: header.payload.signature. Each part is URL-safe Base64 encoded. To decode a JWT payload: (1) Copy the JWT token. (2) Extract the middle section (between the first and second dots). (3) Switch to the Decode tab in this tool, enable URL-Safe option, paste the payload section, and click Decode. The decoded JSON will show you the claims (user ID, expiry time, roles, etc.). Important: Never share JWT tokens — they grant access to accounts. Also, JWT payloads are NOT encrypted — anyone who has the token can decode the payload. Only the signature part verifies authenticity.
🔒 Privacy Note
This Base64 tool runs entirely in your browser using JavaScript. No text, encoded data, or decoded output is ever transmitted to any server or stored anywhere. You can safely use this tool with sensitive data like API keys, tokens, or private text — nothing leaves your device.