Developer Tools

Base64 Decode and Encode

Base64 decode and encode in your browser: turn text into Base64, decode Base64 back to readable text, or encode a file up to 5 MB.

Text to Base64
Base64 to Text
File to Base64
Max 5 MB. Works with images, text files, PDFs, etc.

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

  1. Open the Decode tab.
  2. Paste the encoded string into Base64 Input. The decoded text appears in Decoded Output as you type, or click Decode from Base64.
  3. 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

InputStandard Base64URL-safe
Hello, world!SGVsbG8sIHdvcmxkIQ==SGVsbG8sIHdvcmxkIQ
caféY2Fmw6k=Y2Fmw6k
<<???>>PDw/Pz8+Pg==PDw_Pz8-Pg
{"alg":"HS256"}eyJhbGciOiJIUzI1NiJ9eyJhbGciOiJIUzI1NiJ9

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.

Frequently Asked Questions

Is Base64 the same as encryption?
No. Base64 has no key, so anyone with the encoded string can turn it back into the original, as the Decode tab here shows. It gives no protection to sensitive data, which needs real encryption.
Is my data sent to a server when I use this Base64 converter?
No. Encoding and decoding use the browser's built-in btoa and atob functions, and files are read locally with the FileReader API. The page never uploads what you paste or select, so it is safe to decode configuration strings or payloads from your own applications here.
Why does my Base64 string end with = or ==?
Base64 works in groups of 3 bytes. When the input length is not a multiple of 3, the last group is padded: one leftover byte gives ==, two give =. "M" encodes to TQ==, "Ma" to TWE= and "Man" to TWFu with no padding. URL-safe Base64 usually drops the padding, and this decoder adds it back.
Can I decode Base64 to an image or PDF file here?
No. The Decode tab only turns Base64 into text, and binary data such as an image or PDF triggers the Invalid Base64 message. Save the string to a text file and run base64 -d on Linux, or use Python's base64.b64decode and write the bytes to a file.
Can I use this Base64 decode online tool for URL-safe strings without padding?
Yes. Paste the string as it is. The decoder replaces - with + and _ with /, adds = until the length is a multiple of 4, then decodes. JWT parts and many API tokens use this form, so they decode without editing.
Why is the Base64 output bigger than the input?
Every 3 bytes of input become 4 characters of output, so Base64 is about 33 percent larger, plus up to two padding characters. Text with accented letters grows a little more, because those characters take two or more bytes in UTF-8 before encoding.