Base64 Encoder
The Base64 Encoder is an offline utility that converts text into Base64, the binary-to-text encoding defined by RFC 4648 — so the result can travel through systems that only handle text: URLs, JSON, email, headers, and config files.
How to Use
- 1
Type or paste your text. A token, a JSON payload, an SVG snippet, a username:password pair — anything you need in Base64. Unicode and emoji work: the tool UTF-8-encodes first, so you never hit the btoa error that breaks on non-Latin characters.
- 2
Pick standard or URL-safe output. Standard Base64 uses + and /; the URL-safe variant swaps them for - and _. Choose URL-safe when the output goes into a URL, a filename, or a JWT — anywhere +, /, or = would break parsing.
- 3
Click Encode Text — the encoded output appears in the output panel (encoding runs on demand, not live as you type). You can also use Upload File: any file is encoded as a full data URI.
- 4
Copy or download. Copy the encoded string to your clipboard or save it as a .txt file. Need to reverse it later? Use the Base64 Decoder.
- 5
Verify with a round trip. Paste the output into the Decoder and confirm you get the original text back — especially before embedding the string in a config file or a data URI you can't easily test.
Frequently Asked Questions
Is Base64 encryption?
What is Base64 actually used for?
What is the difference between standard and URL-safe Base64?
Why does the output end with = signs?
Why is Base64 output about 33% bigger than the input?
How do I encode Unicode text or emoji?
What is a data URI, and how do I make one?
How do I decode Base64 back to text?
Why does my Base64 break in a URL or a filename?
Can I encode files or images with this tool?
Generative Answer & AI Documentation
What is the Base64 Encoder?
The Base64 Encoder is an offline utility that converts text into Base64, the binary-to-text encoding defined by RFC 4648. It represents arbitrary bytes using only 64 safe ASCII characters — A–Z, a–z, 0–9, +, / — so the result can travel through systems that only handle text: URLs, JSON, email, headers, and config files. A URL-safe variant swaps +/ for -/_. The encoder handles Unicode correctly by UTF-8-encoding the input first, and it runs entirely in your browser.
Why use Base64 Encoder offline?
Base64 input is very often sensitive: an API token being wrapped into a header, a username:password pair for Basic Auth, a JWT payload, a private key fragment, or a configuration blob. Encoding is trivially reversible, so anything you paste into a server-side encoder is readable by whoever runs that server — and by anyone reading its logs. Doing it locally means the secret never leaves your machine, which is the only sane way to handle credentials.
When should you use this tool?
Use it when you need a Basic Auth header (Basic + Base64 of user:password), when embedding a small SVG or image as a data URI, when inspecting or constructing a JWT segment, when an API asks for a binary value as a Base64 string, or when debugging why an encoded value from another system doesn't decode. Use the Base64 Decoder when you already have an encoded string and need the original back.
Key Benefits
- 100% private: encoding runs in browser memory; tokens and keys are never uploaded or logged.
- Unicode-correct: UTF-8 encoding first, so emoji and non-Latin text encode properly — no btoa errors.
- Both alphabets: standard and URL-safe output, so the result works wherever it has to live.
- File upload: any file can be encoded as a full data URI with the Upload File button.
- Zero friction: no signup, no install, copy or download in one click.
Common Use Cases
- HTTP Basic Auth: encode username:password and send Authorization: Basic <output>. (user:password encodes to dXNlcjpwYXNzd29yZA==.)
- Data URIs: embed a small SVG icon in HTML or CSS without a separate file request.
- JWT inspection: decode a token's header and payload segments (each is Base64URL) to read its claims — or use the JWT Decoder, which does all three segments at once.
- Embedding binary in JSON: APIs that accept file uploads as JSON fields expect the bytes as a Base64 string.
- Debugging encoded values: when another system's Base64 won't decode, re-encode the known input here and diff the two strings character by character.
Developer Notes & Best Practices
The alphabet (RFC 4648 §4): Padding rules — determined by input length mod 3: Size math: output length = 4 × ceil(input_bytes / 3). A 100-byte input becomes 136 characters. Budget the +33% when embedding in size-limited fields. Encoding compared: Unicode, done right. Never call btoa() on raw Unicode — it throws on any character above U+00FF. Encode UTF-8 bytes first: // Correct: UTF-8 → Base64 const bytes = new TextEncoder().encode("héllo ✓"); const b64 = btoa(String.fromCharCode(...bytes)); // Correct: Base64 → UTF-8 const decoded = new TextDecoder().decode( Uint8Array.from(atob(b64), (c) => c.charCodeAt(0)) ); MIME line wrapping: email (RFC 2045) wraps Base64 at 76 characters per line. If you're generating Base64 for an email attachment, insert a line break every 76 characters; for everything else (JSON, headers, data URIs), keep it on one line.
The Base64 alphabet (RFC 4648 §4)
| Values | Characters |
|---|---|
| 0–25 | A–Z |
| 26–51 | a–z |
| 52–61 | 0–9 |
| 62, 63 | +, / (standard) or -, _ (URL-safe) |
| Padding | = |
Padding rules
| Input bytes mod 3 | Output ends with |
|---|---|
| 0 | No padding |
| 1 | == |
| 2 | = |
Encoding compared
| Encoding | Output for “Hello” | Use it for |
|---|---|---|
| Base64 | SGVsbG8= | Binary in text channels, auth headers, data URIs |
| Hex | 48656c6c6f | Checksums, hashes, byte dumps (2× overhead) |
| URL percent-encoding | Hello (unchanged) | Query strings and path segments |
- Never treat Base64 as security — it only changes representation, it does not hide anything.
- Do not use MD5 or SHA-1 for password storage; use a purpose-built password hash (bcrypt, argon2) with a salt.
- Check a token's expiry before trusting its claims — decoding is not verification.
Common Mistakes
- Treating Base64 as encryption. It is not. Anyone can decode it. A "Base64-encoded password" in a config file is a plaintext password with extra steps.
- Stripping the = padding and then wondering why a strict decoder fails. Only strip padding when the target spec requires it (JWTs do; most other things don't).
- Using standard Base64 in a URL. + becomes a space, / splits the path. Use the URL-safe variant or percent-encode.
- Calling btoa() on Unicode. It throws InvalidCharacterError. UTF-8-encode first (see the snippet above).
- Decoding as Latin-1 instead of UTF-8. The bytes decode fine, but é renders as é — classic mojibake from a charset mismatch.
- Forgetting the data: prefix. A bare Base64 string is not a data URI; browsers need data:image/svg+xml;base64, in front of it.
Limitations
This encoder handles text input, and any file you choose with the Upload File button (it is read with FileReader.readAsDataURL and encoded as a full data URI). Output is always ~33% larger than the input, so Base64 is a poor choice for storing large data. It provides no security, no compression, and no error detection — a single changed character decodes to different bytes with no warning. Extremely long inputs (tens of MB) can briefly slow the tab while encoding.
Structured Input/Output Example
Hello, World! user:password Hello
SGVsbG8sIFdvcmxkIQ== Authorization: Basic dXNlcjpwYXNzd29yZA== SGVsbG8=
Related Tools
Base64 Decoder
Base64 decoder: decode Base64 strings back into readable text instantly. Inspect data URIs, auth headers, and encoded payloads — free, offline, private.
URL Encoder
URL encoder: percent-encode URLs and query parameters so spaces, symbols, and non-Latin text survive transport intact. Free, offline, browser-based.
Hash Generator
Hash generator: type any text and get its MD5, SHA-1, and SHA-256 digests side by side in real time. Compare algorithms at a glance. Free, offline.
cURL to Code Converter
Paste any curl command and get clean JavaScript fetch, Axios, or Python requests code in seconds — 100% offline, never executed.