Skip to content
Case Converter Online
en

Base64 Decode and Encode

Encode text to Base64 or decode Base64 back to readable text, with full UTF-8 support. You can also turn a file into Base64 or a data URL, and save Base64 as a file.

Works both ways. Text is read as UTF-8, so accents and emoji survive the round trip.

File to Base64

Output

No file chosen. The file is read on your device and never uploaded.

Base64 to file

Paste Base64 above. The file type is detected where possible.

What Base64 is

Base64 is a way to write any data using only 64 safe characters: the letters A to Z and a to z, the digits 0 to 9, and the symbols + and /. It was designed for systems that can only carry plain text, such as email and some web forms. With Base64, an image, a PDF or text in any language can travel through those systems without being damaged.

You meet Base64 in many places: email attachments, images embedded in CSS as data URLs, JSON Web Tokens, API keys, basic HTTP authentication headers and configuration files.

How to use this Base64 tool

Encode text. Type or paste text into the Text box. The Base64 appears in the right-hand box as you type. Press Copy to take it.

Decode Base64. Paste Base64 into the right-hand Base64 box. The original text appears on the left. Spaces, line breaks, missing padding and a data:...;base64, prefix are all accepted.

Options.

  • URL-safe (- and _) swaps + for - and / for _ and removes the = padding. Use it for links, cookies and file names.
  • Split lines at 76 breaks the output into lines of 76 characters, the layout used in email (MIME).

Clear empties both boxes.

File to Base64. Choose a file of up to 25 MB. Pick Base64 only for the raw string or Data URL for a ready-to-use data:image/png;base64,... value. Then press Copy.

Base64 to file. Paste Base64 or a data URL. The tool detects common types such as PNG, JPEG, GIF, WebP, PDF and ZIP, suggests a file name, and shows a preview for images. Press Download file to save it.

How Base64 works

Base64 reads the input three bytes (24 bits) at a time. It splits those 24 bits into four groups of 6 bits. Each 6-bit group is a number from 0 to 63, and that number picks one character from the Base64 alphabet. Three bytes in, four characters out. This is why Base64 output is about one third larger than the input.

Text is first turned into bytes with UTF-8. That is why accented letters and emoji work here: café becomes 5 bytes, and those bytes are encoded. Some older tools use the browser function btoa directly, which fails on any character outside Latin-1.

Examples

Input Base64 URL-safe
M TQ== TQ
Ma TWE= TWE
Man TWFu TWFu
Hello, World! SGVsbG8sIFdvcmxkIQ== SGVsbG8sIFdvcmxkIQ
café Y2Fmw6k= Y2Fmw6k
Zoë Wm/Dqw== Wm_Dqw
<?> PD8+ PD8-

The last two rows show why the URL-safe form exists. A / or + inside a link can break it, while _ and - are safe.

Tips and limits

  • Base64 is not security. It hides nothing. Treat Base64 text the same as the original data.
  • Check the error message. If you paste something with a character such as *, the tool tells you which character is not valid Base64.
  • Binary data needs a file. If the decoded bytes are not valid UTF-8 text, the tool says so. Paste the same Base64 into Base64 to file and download it instead.
  • Size grows. A 3 MB image becomes roughly 4 MB of Base64. Inline data URLs are handy for small icons but slow for large photos.
  • Padding is optional when decoding. The tool adds the missing = signs for you.

Other ways to encode Base64

Command line (macOS and Linux). echo -n 'Hello, World!' | base64 prints SGVsbG8sIFdvcmxkIQ==. Use base64 -d (or base64 -D on older macOS) to decode. Leave out -n and you encode a trailing new line too.

Windows. certutil -encode input.txt output.txt encodes a file. In PowerShell, [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes('Hello, World!')) encodes text.

JavaScript (Node). Buffer.from('Hello, World!').toString('base64') returns SGVsbG8sIFdvcmxkIQ==, and Buffer.from('SGVsbG8=', 'base64').toString() returns Hello.

Python. base64.b64encode('Hello, World!'.encode()).decode() gives the same result. Note that base64.urlsafe_b64encode keeps the = padding, so Zoë becomes Wm_Dqw==.

To make text safe for a web address, use the URL encoder and decoder. To see the raw bytes behind your text, try the hex to text converter or the UTF-8 encoding tool.

Base64 Encoder: questions and answers

How do I decode Base64 to text?

Paste the Base64 into the right-hand box. The decoded text appears on the left as you paste. For example, SGVsbG8sIFdvcmxkIQ== decodes to Hello, World!. If the data is an image or another file, use the Base64 to file panel instead.

Is Base64 a form of encryption?

No. Base64 only changes how bytes are written. Anyone can decode it in a second, with no key or password. Never use it to hide passwords, tokens or personal data.

What is URL-safe Base64?

It is Base64 with two characters swapped so it can sit inside a link or a file name: + becomes - and / becomes _. The = padding at the end is usually dropped. The text Zoë becomes Wm/Dqw== in standard Base64 and Wm_Dqw in the URL-safe form. This tool decodes both.

Why does my Base64 end with one or two = signs?

Base64 turns every 3 bytes into 4 characters. When the input length is not a multiple of 3, the last group is padded with = so the output stays a multiple of 4. Ma encodes to TWE= and M encodes to TQ==.

Are my files uploaded?

No. Files are read by your browser and converted on your device. Nothing is sent to a server, so you can safely convert private documents.

More code and data tools

See all tools