What is Base64 Encoder & Decoder?
This Base64 decode and encode tool converts text to Base64 and Base64 back to text. Base64 represents any data using 64 safe characters (A–Z, a–z, 0–9, + and /), so binary data and special characters can travel through systems that only handle plain text, such as HTTP headers, JSON fields, email bodies, URLs and environment variables.
Choose Encode to turn text into Base64, or Decode to turn a Base64 string back into readable text. Text is handled as UTF-8, so accented letters, non-Latin scripts and emoji survive the round trip, and the decoder is forgiving: it accepts URL-safe Base64 (- and _), ignores whitespace and line breaks, and adds missing = padding.
How to use Base64 Encoder & Decoder
- Choose Encode to convert text to Base64, or Decode to convert Base64 to text.
- Paste your text or Base64 string into the input panel.
- The result appears in the output panel instantly.
- Copy the result or download it as a file.
Key features
- Encode text to Base64 and decode Base64 to text
- Full UTF-8 support, including emoji and non-Latin scripts
- Accepts URL-safe Base64 (- and _) when decoding
- Ignores whitespace and adds missing = padding
- Clear messages for input that is not Base64
- Runs entirely in your browser
Common use cases
- Decoding Base64 values in API responses, headers and webhooks
- Encoding credentials or config values for environment variables and Kubernetes Secrets
- Reading Base64-encoded email bodies and attachments' text
- Inspecting the payload of tokens and cookies
- Encoding text for data: URIs and JSON fields
Technical details & standards
Encoding converts the text to UTF-8 bytes and then to standard Base64 (RFC 4648, section 4) with = padding. Every 3 bytes become 4 characters, so Base64 output is about 33% larger than the input.
Decoding accepts both the standard and the URL-safe alphabet (RFC 4648, section 5), strips whitespace, restores missing padding, and decodes the bytes as UTF-8. If the input is not Base64 at all, or decodes to binary data that is not text, you get a clear explanation rather than garbled output; for binary files such as images or PDFs, use File to Base64 or the matching converter. Base64 is an encoding, not encryption: anyone can decode it.
How to decode Base64 by hand: Zm9v
Decoding is encoding run backwards: each character is a 6-bit number, four characters make 24 bits, and those bits are cut into three bytes. Here is Zm9v:
- Look up each character in the alphabet (A–Z = 0–25, a–z = 26–51, 0–9 = 52–61, + = 62, / = 63): Z = 25, m = 38, 9 = 61, v = 47.
- Write each value as 6 bits: 011001, 100110, 111101, 101111.
- Join the 24 bits and cut them into bytes: 01100110 01101111 01101111.
- Read the bytes as numbers and characters: 102 = f, 111 = o, 111 = o.
Result: Zm9v decodes to foo. With padding the last group is shorter: Zm8= is the two bytes fo and Zg== is the single byte f, because each = stands for bits that were only added to fill the group and are thrown away.
Base64 decode in JavaScript, Python and the terminal
To decode Base64 in your own code, turn the string into bytes and then read them as UTF-8; atob() on its own returns each byte as a Latin-1 character, so accented letters and emoji come out garbled. Each snippet decodes aMOpbGxvIOKckw== to héllo ✓.
JavaScript (browser)
const fromBase64 = b => new TextDecoder().decode(Uint8Array.from(atob(b), c => c.charCodeAt(0)));
fromBase64("aMOpbGxvIOKckw=="); // "héllo ✓"
// Base64URL: swap the two characters and restore the padding first
const fromBase64Url = s => fromBase64(s.replace(/-/g, "+").replace(/_/g, "/").padEnd(Math.ceil(s.length / 4) * 4, "="));JavaScript (Node.js)
Buffer.from("aMOpbGxvIOKckw==", "base64").toString("utf8"); // "héllo ✓"
Buffer.from(token, "base64url").toString("utf8"); // Base64URL, padding optionalNode.js reads both Base64 alphabets and does not need the = padding.
Python
import base64
base64.b64decode("aMOpbGxvIOKckw==").decode("utf-8") # 'héllo ✓'
base64.urlsafe_b64decode(s + "=" * (-len(s) % 4)) # Base64URL, padding restoredTerminal
echo 'aMOpbGxvIOKckw==' | base64 -d # héllo ✓On older versions of macOS the decode flag is -D.
Decode Base64URL text with missing padding
URL-safe Base64 replaces + and / with - and _. Some APIs also omit the trailing equals signs. The decoder accepts this form directly.
Example input
8J-YgA- Choose Decode and paste 8J-YgA into the input.
- Check that the result is a single emoji. The equivalent padded standard Base64 is 8J+YgA==.
- If the decoded bytes belong to a file rather than UTF-8 text, use the file converter to download them.
Expected result
😀Continue with a related task:
Frequently asked questions
Can I decode a Base64 data URI?
Yes. Paste a value such as data:text/plain;base64,SGVsbG8= and choose Decode to read Hello. For images or other binary files, use the corresponding Base64 file converter.
How do I decode Base64?
Select Decode and paste the Base64 string; the decoded text appears immediately. In code, use atob() in JavaScript (with UTF-8 handling) or base64.b64decode() in Python. On the command line: echo 'SGVsbG8=' | base64 -d on Linux and macOS, [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('SGVsbG8=')) in PowerShell, or certutil -decode input.txt output.txt in the Windows Command Prompt.
Is Base64 encryption?
No. Base64 is a reversible encoding with no key, so anyone can decode it. Never rely on it to protect passwords or secrets; use real encryption for that.
Why is Base64 output longer than the input?
Base64 stores every 3 bytes as 4 characters, so encoded data is about 33% larger, plus up to two = padding characters.
What is URL-safe Base64?
A variant that replaces + with - and / with _ so the string can be used in URLs and file names, usually without = padding. JWTs use it. This decoder accepts both variants.
What is Base64 encoding?
A way to write any data, including binary files, using 64 safe text characters: A–Z, a–z, 0–9, + and /, with = as padding. Every 3 bytes become 4 characters, so "Hi" encodes to SGk= and "Hello" to SGVsbG8=. It lets images, files and keys travel through text-only channels such as JSON, email and data URIs.
How do I Base64 encode in Python or JavaScript?
Python: base64.b64encode(b"Hello").decode() returns 'SGVsbG8=' and base64.b64decode("SGVsbG8=") returns b'Hello'; use base64.urlsafe_b64encode for URL-safe output. JavaScript: btoa("Hello") and atob("SGVsbG8=") for ASCII text, or Buffer.from(text).toString("base64") in Node.js.
How do I recognise Base64 in logs or network traffic?
Look for long runs of A–Z, a–z, 0–9, + and / whose length is a multiple of 4, often ending in = or ==. The first characters also give away what was encoded: eyJ is JSON (a JWT starts this way), iVBORw is a PNG, JVBERi a PDF, H4sI gzip data, PD94bW an XML declaration and TVqQ a Windows executable. Paste the string here to decode it.
How can I tell how many bytes a Base64 string holds?
Every 4 characters hold 3 bytes, minus one byte for each = at the end. Zm9vYmFy (8 characters, no padding) holds 6 bytes, and Zm9vYg== (8 characters, two =) holds 4. If the length, ignoring any padding, leaves a remainder of 1 when divided by 4, the string cannot be valid: it was cut off or damaged.
Why does my Base64 fail to decode or show strange characters?
Usual causes: the string contains characters outside the Base64 alphabet, such as @, quotes or escaped \n sequences copied from JSON; it was truncated; it holds binary data such as an image or a compressed file rather than text; or the text was encoded in another character set such as Windows-1252 and so does not read back as UTF-8. This tool trims whitespace, accepts URL-safe characters, restores missing padding and says plainly when the result is not text.
How do I decode a Base64URL string, such as a JWT segment?
Replace - with + and _ with /, add = until the length is a multiple of 4, then decode as standard Base64. A strict decoder fails without that step, and a lenient one may drop the - and _ characters and return the wrong bytes. This decoder does the conversion for you; to read a whole token, paste it into the JWT Decoder.
What is the Base64 alphabet?
64 characters: A–Z are the values 0–25, a–z are 26–51, 0–9 are 52–61, + is 62 and / is 63. The = sign is not part of the alphabet; it only pads the end. Base64URL uses - and _ in place of + and /.
Why do Base64 emails and certificates have line breaks?
MIME (RFC 2045) wraps Base64 at 76 characters per line and PEM files for certificates and keys at 64, because old mail systems limited line length. Line breaks carry no data, so wrapped and unwrapped text decode to the same bytes, and this tool ignores them. Wrapping makes the text about 37% larger than the original instead of 33%.
What do common Base64 strings decode to?
SGVsbG8gV29ybGQ= is Hello World, dXNlcjpwYXNz is user:pass (the shape of a Basic auth value), YWRtaW4= is admin, dGVzdA== is test, MTIzNDU2 is 123456, and eyJhbGciOiJIUzI1NiJ9 is {"alg":"HS256"}, the header of many JWTs.
Is my data safe?
Processing happens locally in your browser. Tool input is not sent to CodeUnpack servers.
Does it work offline?
Once the page has loaded, this tool can process input without an internet connection.