Base64 encoder and decoder

The Base64 encoder and decoder encodes text to Base64 and decodes Base64 back to text in any language, and converts a file to Base64 and a Data URL.
Text
Enter text to encode or Base64 to decode.
Encoding uses - and _ instead of + and /, without = at the end. Decoding accepts both forms, with or without =.
The text was encoded. Characters in the result: 40.
File
Up to 5 MB.

Everything runs in your browser; nothing is sent or stored.

  • Enter text and click "Encode", or paste Base64 and click "Decode". Text is encoded as UTF-8, so accented letters, non-Latin scripts, and any Unicode character are fully preserved.
  • Tick "URL-safe Base64" to get an encoding that fits inside a URL.
  • When decoding, you can paste either form, with or without = signs at the end.
  • In the "File" section, choose a file to get its content in Base64 and its Data URL. Each result has its own "Copy" button.

What is Base64

Base64 represents binary data with 64 characters: the letters A-Z and a-z, the digits 0-9, and the symbols + and /. Every 3 bytes of input become 4 characters of output, so the size grows by about a third. When the number of input bytes is not divisible by 3, one or two = signs are added at the end as padding. Base64 lets you send files and binary data over channels designed for text, such as email messages, JSON, or HTML.

Base64 and non-ASCII text

In UTF-8, an English letter takes one byte, while an accented letter such as é, or a letter in Greek, Cyrillic, Hebrew, or Arabic, takes 2 bytes. Text written entirely in such a script therefore grows about 2.7 times when encoded in Base64. For example, the word "café" has 4 letters but 5 bytes, and becomes 8 Base64 characters.

What is a Data URL

A Data URL holds the file type and the file content in Base64 in a single string that starts with data:. When the file type is not recognized, the converter uses the generic type application/octet-stream. Data URLs suit small files, such as icons, because a large file increases the size of the page.

Where you see Base64

Email attachments are encoded in Base64 inside the message, and in the message headers, a subject with non-ASCII characters often appears as a string that starts with =?UTF-8?B?. SSL certificates and keys in PEM format are also Base64 between a BEGIN line and an END line, and you can read the content of a certificate with the "SSL certificate decoder" tool. A JWT is made of three URL-safe Base64 parts separated by dots, and you can read the parts with the "JWT decoder" tool.

Common mistakes

Using standard Base64 inside a URL corrupts the value: in URL parameters, the + sign is read as a space, and the / sign is read as a path separator. In URLs, we recommend the URL-safe form, or encoding the value with the "URL encoder and decoder" tool.

Another common mistake is double encoding: when an encoded value is encoded again, decoding returns a Base64 string instead of the original text, and you need to decode the result once more. A Data URL includes the file type before the content, so before decoding, copy only the part after the comma.

Examples

  • SGVsbG8=the encoding of the word Hello.
  • Y2Fmw6k=the encoding of the word "café": 5 bytes in UTF-8 and 8 Base64 characters.
  • YQ==the encoding of the character a: one input byte, so two = signs are added as padding.
  • YWJjthe encoding of abc: exactly 3 bytes, so no padding is needed.
  • Pz8+ and Pz8-the encoding of ??> in the standard form and in the URL-safe form.
  • YWRtaW46c2VjcmV0the encoding of admin:secret, as it appears in a Basic authentication header.
  • data:image/png;base64,iVBORw0KGgo...the beginning of the Data URL of a PNG image.

Base64 encoder and decoder FAQ

Does Base64 encrypt my data?

Base64 is an encoding, not encryption, and anyone can decode it without a key or a password. For example, in Basic authentication, the username and password are sent in the Authorization header as plain Base64, and their protection depends on an encrypted HTTPS connection. Sensitive data needs encryption.

Why does it say the decoded content is not valid text?

The converter decodes Base64 to text only, so the message appears when the Base64 represents a file, such as an image, a PDF, or an archive. It also appears when the original text was encoded in a character encoding other than UTF-8, such as Windows-1252.

What is the difference between standard Base64 and URL-safe Base64?

In the URL-safe form (Base64URL), the + character is replaced with a hyphen (-), the / character is replaced with an underscore (_), and the = signs at the end are dropped. This lets you put the value in a URL without further encoding, and JWTs use this form too. The option applies to text encoding, and the Base64 of a file is always shown in the standard form.

Why is my input rejected as invalid Base64?

The input is rejected when it contains characters that are not part of Base64, such as a period, @, or letters outside A-Z and a-z, or when its length is not possible, for example after a partial copy. Spaces and line breaks do not cause an error, because the converter ignores them.

What is the maximum file size I can convert?

The converter accepts files of up to 5 MB, and text to encode or decode is also limited to 5 MB. A 5 MB file becomes about 7 million Base64 characters.

How do I use a Data URL?

You can paste a Data URL into the src attribute of an img tag or into the url() function in CSS, instead of a file URL. The browser displays the file from the value itself, without a separate request to the server.

Shopping cart

Your cart is emptyYou can start with one of our popular plans.

Site search

Accessibility

Text size
100%
Accessibility statement