Base64 Encoder & Decoder · Base64 Switch
Encode and decode text, JSON or small files as Base64. Your data never leaves your browser.
Updated:
Input
Output
What is Base64?
Base64 is a way of representing binary data — files, images, raw bytes — using only plain text characters, so it can safely travel through systems that only understand text, like JSON, URLs or email. It doesn't compress or encrypt anything; it just re-packages the same data into a text-safe form, which is why decoding it gives you back exactly what you started with. This tool lets you go from text/file to Base64 (encode) or from Base64 back to text/file (decode).
How to use the Base64 encoder & decoder
- Pick Encode or Decode at the top of the Input panel.
- Type or paste your content into Input, or use Paste, Upload file, or Example.
- Read the converted result in the Output panel.
- Click Copy to copy it, or Download to save it as a file.
How Base64 encoding works
Base64 represents binary data (bytes) using only 64 printable characters (A-Z, a-z, 0-9, + and /), grouping every 3 input bytes into 4 output characters. It's the standard format for embedding images in CSS, attaching files in JSON, or carrying binary data through text-only contexts:
// Encode "Hello, DeveloTools!" → "SGVsbG8sIERldk1hdHJpeCE=" // Decode "SGVsbG8sIERldk1hdHJpeCE=" → "Hello, DeveloTools!"
This tool uses the browser's native TextEncoder/TextDecoder and btoa/atob to make sure text with accents and emoji (UTF-8) encodes and decodes without corruption — no external libraries, no server calls.
Examples
1. Encode plain text. 13 bytes of ASCII become 20 Base64 characters; the two = signs pad the last group to a multiple of four:
Input: Hello, world! Output: SGVsbG8sIHdvcmxkIQ== (20 characters · 13 input bytes)
2. Encode text with accents and emoji. The tool encodes the UTF-8 bytes, not the characters: café ☕ is 6 characters but 9 bytes (é takes 2, ☕ takes 3). Browsers' bare btoa("café ☕") throws an error on that input; this tool doesn't:
Input: café ☕ Output: Y2Fmw6kg4piV (12 characters · 9 input bytes)
3. Decode an HTTP Basic Auth header. The value after Authorization: Basic is just user:password in Base64 — which is why Basic Auth must only travel over HTTPS:
Input: YWRtaW46czNjcjN0 Output: admin:s3cr3t
Decoding is also lenient with the URL-safe alphabet used in JWTs: eyJzdWIiOiI0MiJ9 (no padding) decodes to {"sub":"42"}.
Common Base64 errors and how to fix them
- Characters outside the alphabet. Base64 only uses A–Z, a–z, 0–9,
+and/(or-and_in the URL-safe variant). PastingSGVsbG8*shows Invalid Base64: contains characters outside the … alphabet. Usually the string was cut from a larger text and dragged a quote, a comma or a%3D(URL-encoded=) along with it. - Wrong length. Every 4 characters encode 3 bytes, so a string whose length leaves a remainder of 1 when divided by 4 can't be valid:
SGVsbG8gdgives wrong length to decode. The string was truncated — copy it again in full. A missing=padding alone is not an error; the tool restores it. - Mojibake after decoding. If é turns into é, the original was encoded from a different character set (often Windows-1252 or Latin-1) and decoded as UTF-8, or the other way round. Re-encode the source as UTF-8.
- Binary output that isn't text. When the decoded bytes are not valid UTF-8 (an image, a PDF, a compressed file), the tool doesn't print garbage: it reports the byte count and offers the result as a file download.
- Treating Base64 as encryption. Anyone can reverse it, as example 3 shows. Use it to transport bytes through text-only channels, never to hide secrets.
Base64 encoder vs. the command line
On Linux and macOS, echo -n 'Hello, world!' | base64 encodes and echo 'SGVsbG8sIHdvcmxkIQ==' | base64 --decode decodes (-D on older macOS); the -n matters, or the trailing newline gets encoded too. On Windows, PowerShell needs [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes('Hello, world!')), or certutil -encode for files. The browser tool saves those details and handles URL-safe input without converting it first. The alphabet and padding rules are defined in RFC 4648. If the string you are decoding has three dot-separated parts, it is a JWT: the JWT Decoder splits and decodes all three at once. To see how much an image grows when embedded as a data URI, use the Base64 Data URI Size Checker.
Frequently asked questions
Is it safe to upload a file to this Base64 converter?
Yes. The file is read with the browser's File API and never sent to a server — all encoding happens locally on your machine.
What's the difference between standard Base64 and Base64URL?
Base64URL replaces the '+' and '/' characters with '-' and '_' so the result is URL-safe; this tool accepts both variants when decoding.
Can I decode Base64 that represents a binary file, not text?
Yes. If the result isn't valid UTF-8 text, the tool detects that and lets you download the original bytes instead of showing broken text on screen.
How much bigger does Base64 make the data?
About 33% larger than the original, because every 3 input bytes are represented with 4 output characters.