Use this page to Base64 decode a string back to readable text, or to encode text and files to Base64. Base64 turns binary data into plain text so it can travel through formats built for text, such as JSON, URLs and email. The tool runs entirely in your browser, so nothing you paste or select is sent to a server.
How to Base64 decode a string
- Open the Decode tab.
- Paste the encoded string into Base64 Input. The decoded text appears in Decoded Output as you type, or click Decode from Base64.
- Click Copy Text to copy the result. The line beside the button compares the size of the input and the output.
The Base64 decoder accepts both alphabets. It turns URL-safe characters (- and _) back into + and / and adds missing = padding before decoding, so a string copied from a URL or one segment of a JWT works without changes. If the input is not valid Base64, a red "Invalid Base64" message appears instead of output.
How to Base64 encode text or a file
Text
Type or paste into the Encode tab. The output updates as you type, and the line under it shows the byte sizes and the character count. Text is converted to UTF-8 before encoding, so accented letters and non-Latin scripts encode the same way they do in Python or the base64 command. Tick URL-safe encoding to swap + for -, / for _ and drop the trailing = padding.
Files
The File Encode tab reads one file of up to 5 MB of any type and shows its name, size, MIME type and Base64 length. The Base64 Output box shows only the first 100 characters, and Copy Base64 copies that preview, not the whole string. Copy as Data URI copies the complete result, starting with data:, the MIME type and ;base64,. Delete everything up to and including the comma if you need the raw Base64. For images, the image to Base64 converter also gives ready-made CSS and HTML snippets.
Examples you can check
| Input | Standard Base64 | URL-safe |
|---|---|---|
Hello, world! | SGVsbG8sIHdvcmxkIQ== | SGVsbG8sIHdvcmxkIQ |
café | Y2Fmw6k= | Y2Fmw6k |
<<???>> | PDw/Pz8+Pg== | PDw_Pz8-Pg |
{"alg":"HS256"} | eyJhbGciOiJIUzI1NiJ9 | eyJhbGciOiJIUzI1NiJ9 |
Base64 writes every 3 bytes as 4 characters, so the 13 bytes of "Hello, world!" become 20 characters, about a third larger. "café" is 5 bytes in UTF-8 because é takes two. The last row is the header of a JSON Web Token; the JWT decoder splits and decodes all three parts of a token at once.
Base64 decode on the command line
When the encoded data is a file rather than text, run the Base64 decode outside the browser:
# Linux (GNU coreutils)
echo 'SGVsbG8sIHdvcmxkIQ==' | base64 -d
base64 -d encoded.txt > image.png
# Python
python3 -c "import base64; print(base64.b64decode('SGVsbG8sIHdvcmxkIQ==').decode())"
# PowerShell
[Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('SGVsbG8sIHdvcmxkIQ=='))
The echo, Python and PowerShell lines print "Hello, world!". The base64 -d encoded.txt line writes the decoded bytes straight to a file, which is how you recover an image or PDF.
Limits and common errors
- A Base64 decode here always produces text. If the Base64 holds an image, PDF or other binary file, the bytes are not valid UTF-8 and you get the Invalid Base64 message. Use the command-line method above.
- Remove line breaks before decoding. Base64 copied from an email source or a PEM file is often wrapped at 64 or 76 characters, and the decoder can reject wrapped input.
- Base64 is an encoding, so anyone can reverse it. It hides nothing from someone who has the string, so never use it to protect passwords or keys.
I mainly use Base64 to embed tiny SVG icons or font snippets directly in CSS, which saves a separate HTTP request for each one. Be careful with large images: the output is about a third larger than the original file, so a big image inlined this way makes the stylesheet much heavier. For background, read what Base64 encoding is and Base64 vs hex encoding. More encoders and converters are in the developer tools section.