Base64 Encoder / Decoder
Convert text to Base64 or Base64 back to text — free, instant, and fully private. Your text and files never leave your browser.
Input: 0 characters (0 bytes) - Output: 0 characters (0 bytes)
Choose a file to convert it to Base64. Files never leave your browser — everything runs locally. Files up to 10 MB are supported.
Base64 to fileAfter decoding, download the decoded bytes as a file. Useful for images, PDFs and other binary data.
Note: Base64 is not encryption — it only changes how text looks, using safe characters. Anyone can decode a Base64 string, so never use it to "hide" a password or secret.
Base64 is everyday work for API keys, tokens, data URLs and JWTs — now it runs entirely in your browser, with no sign-up.
How to use the Base64 encoder in 3 steps
Base64 is a way to turn any text or binary data into safe characters only (A-Z, a-z, 0-9, +, / and =). It is used in email, data URLs, APIs and tokens. This tool does the conversion entirely in your browser.
Step 1: type text in the input box, paste a Base64 string, or choose a file. Step 2: press Encode or Decode — with Live mode on, the result appears as you type. Step 3: copy the output, download it as a .txt file, or download the decoded bytes as a file.
How Base64 works: 3 bytes become 4 characters
Base64 takes every 3 bytes (24 bits) of input and splits them into 4 groups of 6 bits. Each 6-bit group (a value from 0 to 63) maps to one character of the Base64 alphabet. If the input is not a multiple of 3 bytes, = padding is added at the end. That is why Base64 output is about 33% larger than the input.
Example — the word "Man" is 3 bytes: M = 77, a = 97, n = 110. In binary that is 01001101 01100001 01101110. Split into 6-bit groups: 010011 (19 = T), 010110 (22 = W), 000101 (5 = F), 101110 (46 = u). So "Man" encodes to "TWFu".
Worked examples
| Input | Base64 output | Notes |
|---|---|---|
| Hello | SGVsbG8= | 5 characters, 5 bytes, one = of padding |
| Hello World | SGVsbG8gV29ybGQ= | 11 characters, 11 bytes |
| Man | TWFu | 3 bytes, no padding needed |
| user:password | dXNlcjpwYXNzd29yZA== | Basic Auth format: username:password |
| السلام علیکم | 2KfZhNiz2YTYp9mFINi52YTbjNqp2YU= | Urdu text, 23 UTF-8 bytes |
| 😀 | 8J+YgA== | One emoji, 4 UTF-8 bytes |
Base64 vs Base64URL
| Feature | Base64 (standard) | Base64URL |
|---|---|---|
| Alphabet | A-Z, a-z, 0-9, +, / | A-Z, a-z, 0-9, -, _ |
| Padding | = at the end | Usually none |
| Safe in a URL? | No (+, / and = have special meanings in URLs) | Yes |
| Used for | Email (MIME), data URLs, XML, JSON | JWT tokens, URLs, filenames |
| Standard | RFC 4648 section 4 | RFC 4648 section 5 |
This tool accepts both on decode automatically: it normalises - to + and _ to /, and adds any missing padding. Tick "URL-safe output" to produce Base64URL when you encode.
Base64 in code
JavaScript (browser, UTF-8 safe):
// Encode
const bytes = new TextEncoder().encode("Hello World");
const base64 = btoa(String.fromCharCode(...bytes));
console.log(base64); // SGVsbG8gV29ybGQ=
// Decode
const decoded = new TextDecoder().decode(
Uint8Array.from(atob(base64), c => c.charCodeAt(0)));
Node.js:
const base64 = Buffer.from("Hello World", "utf8").toString("base64");
console.log(base64); // SGVsbG8gV29ybGQ=
const text = Buffer.from(base64, "base64").toString("utf8");
Python:
import base64
encoded = base64.b64encode(b"Hello World").decode("ascii")
print(encoded) # SGVsbG8gV29ybGQ=
decoded = base64.b64decode(encoded).decode("utf-8")
What is Base64 used for?
Base64 is used whenever binary data or special characters must travel through a channel that only accepts plain text: email attachments (MIME), images embedded in a web page as data URLs, API tokens and Basic Auth headers (Authorization: Basic dXNlcjpwYXNzd29yZA==), the three parts of a JWT, and binary data stored inside JSON. It does not make data smaller — output is about 33% larger — it only makes it safe to carry.
Is Base64 encryption?
No. Base64 is only an encoding, not encryption. Anyone can decode a Base64 string in one click, so never treat it as a way to hide a password or a secret. For real secrecy, use proper encryption.
Troubleshooting
Bad character at position N: the string contains a character outside the Base64 alphabet. Check the position named in the message — often a character was lost or added while copying, or the string is a URL with extra text around it.
Bad length: a valid Base64 string has a length that is a multiple of 4. This tool adds missing = padding automatically, so a length error means characters are missing or extra.
Decoded bytes are not valid UTF-8: the Base64 itself is fine, but the result is a binary file (image, PDF, ZIP), not text. Switch the decode output to Hex or Hexdump, or use "Download decoded file".
JWT segment will not decode: JWT parts use Base64URL (- and _ instead of + and /, usually with no padding). This tool detects and decodes them automatically — paste the full segment.
Base64 Encoder FAQ
Is the Base64 encoder free?
Yes. It is completely free, needs no login or sign-up, and there is no limit on how many times you use it.
Is Base64 encryption?
No. Base64 is only an encoding, not encryption. Anyone can decode a Base64 string in one click, so never use it to hide a password or secret.
Does it work with Urdu text and emoji?
Yes. The tool encodes text as UTF-8 first (using TextEncoder/TextDecoder), so Urdu text such as السلام علیکم and emoji such as 😀 round-trip correctly.
What is Base64URL and when should I use it?
Base64URL is the URL-safe variant of Base64 (RFC 4648 section 5). It replaces + with -, / with _, and drops the = padding, so the output is safe to put in a web address or a JWT. Use it for URLs and tokens; use standard Base64 for email (MIME) and data URLs.
Why does decoding say there is a bad character?
The decoder names the exact problem — for example, a bad character at a given position, or a length that is not a multiple of 4. Common causes are a character lost or added while copying, or a pasted JWT or URL-safe string. This tool removes whitespace and adds missing padding automatically, so check the character at the position named in the message.
Can I encode a file to Base64?
Yes. Choose a file up to 10 MB and the tool converts it to Base64 in your browser, with an optional data URL output that includes the correct MIME type. You can also decode Base64 back to a file and download it. Files never leave your browser.
Is my text or file sent to a server?
No. Everything runs in your browser with JavaScript. Your text and files are never uploaded, stored or shared anywhere.
Related tools
JSON Formatter — validate and beautify JSON, including data that carries Base64 values. QR Code Generator — turn text or a link into a QR code. Password Generator — create strong random passwords (never hide one in Base64 — it is not encryption).
Last updated: 20 November 2026
No comments:
Post a Comment