DevTools Pro · All tools · About

Base64 Encoder/Decoder

About the Base64 Encoder/Decoder

This Base64 encoder and decoder converts UTF-8 text or any file to Base64 and back as you type, with an optional URL-safe (base64url) output. It is handy for building data URIs, reading encoded API fields and checking what an encoded string actually contains, all without sending your data anywhere.

What is Base64 encoding?

Base64 represents binary data using 64 printable ASCII characters: A-Z, a-z, 0-9, + and /. Every 3 bytes of input become 4 characters of output, and = pads the end when the input length is not a multiple of 3.

For example, Man encodes to TWFu, Hello to SGVsbG8= and the single letter a to YQ==. Because 3 bytes turn into 4 characters, Base64 output is roughly 33% larger than the original data.

Base64 vs base64url

Standard Base64 uses + and /, which have special meaning in URLs and file names. The URL-safe variant from RFC 4648 swaps them for - and _ and usually drops the = padding. JWTs, many OAuth parameters and some storage keys use this form.

The bytes <<???>> encode to PDw/Pz8+Pg== in standard Base64 and PDw_Pz8-Pg in base64url. This decoder accepts either form, with or without padding, and ignores whitespace and line breaks.

Text, UTF-8 and binary files

Base64 encodes bytes, not characters, so text has to be turned into bytes first. This tool uses UTF-8, the same as most languages and APIs: é becomes the two bytes C3 A9 and encodes to w6k=. Tools that use Latin-1 or UTF-16 will give a different result for non-ASCII text.

When decoding, the result is shown as text only if the bytes are valid UTF-8. If the Base64 holds an image, PDF or other binary data, you get a "Decoded data is binary" message instead of garbled characters.

Base64 is not encryption

Anyone can decode Base64 instantly; it only changes how data is represented. HTTP Basic auth headers such as Authorization: Basic dXNlcjpwYXNz are just user:pass in Base64, which is why they must only travel over HTTPS. Never use Base64 to hide secrets.

How to Use the Base64 Encoder/Decoder

  1. Choose the Encode or Decode tab, then type or paste into the input box. Click "Encode a file" to load any file, or "Load Example" to fill in a sample.
  2. Turn on "URL-safe (base64url, no padding)" if the result will go into a URL, file name or JWT. The output updates as you type, and errors such as invalid characters or a bad length appear below the panels.
  3. Click Copy Result to copy the output or Download to save it as a text file. "Flush Buffer" clears both fields.

Base64 Encoder/Decoder Examples

Encode plain text

Encode tab, URL-safe off.

Input:

Hello, World!

Output:

SGVsbG8sIFdvcmxkIQ==

Encode text with accents and symbols

Encode tab, URL-safe off. The text is converted to UTF-8 bytes first, so the output is longer than for plain ASCII.

Input:

Hello, World! Café ✓

Output:

SGVsbG8sIFdvcmxkISBDYWbDqSDinJM=

Decode base64url without padding

Decode tab. URL-safe characters (- and _) and missing = padding are accepted.

Input:

PDw_Pz8-Pg

Output:

<<???>>

Common Errors

Invalid Base64: contains characters outside A-Z a-z 0-9 + / - _ = (you pasted a data URI such as data:image/png;base64,iVBOR...)
Paste only the part after base64,. The data:image/png;base64, prefix is not Base64 and is rejected.
Invalid Base64: incorrect length
The string is truncated or has an extra character: a valid length is never one more than a multiple of 4 once padding is removed. Copy the whole value again.
Decoded data is binary, not valid UTF-8 text
The Base64 is valid but holds an image, PDF or other non-text data, which cannot be shown as a string. To get an image back from Base64, use the Base64 Image Converter.
The output differs from echo hello | base64 on the command line
echo adds a trailing newline that Base64 encodes too. Use echo -n hello | base64, or make sure your input here has no trailing line break.

Frequently Asked Questions

Is my data uploaded when I encode a file?
No. Files are read with the browser's File API and encoded locally in JavaScript. Nothing is sent to a server.
Why is my Base64 output bigger than the input?
Base64 uses 4 characters for every 3 bytes, so output is about 33% larger, plus up to two = padding characters.
What does the = at the end mean?
It is padding that makes the output length a multiple of 4. One = means the last group held 2 bytes, two == means it held 1 byte. base64url usually leaves it off.
Why do I get "Decoded data is binary, not valid UTF-8 text"?
The Base64 decodes to bytes that are not text, such as an image or compressed data. The input is valid Base64; it just cannot be shown as a string.
Why does my result differ from another tool?
Usually because of text encoding or a trailing newline. This tool encodes text as UTF-8, and commands like echo add a newline unless you use echo -n.

Related tools