Base64 Encoder/Decoder

Free Base64 Encoder and Decoder — convert text, files, and images to Base64 encoding and back. Essential developer tool for working with REST APIs, data URIs, JWT tokens, email attachments (MIME), and embedded resources in HTML/CSS.

Free online tool · Developer Tools · No installation · No sign-up required

Overview

Base64 encoding is a cornerstone of modern data transmission, providing a robust method for converting binary data into a text-based format. This process is essential when binary data, such as images, videos, or executable files, needs to be sent over systems that are designed to handle only text. The encoding works by taking the binary data and breaking it down into 6-bit chunks. Each 6-bit chunk is then mapped to one of 64 characters from a predefined set, which typically includes uppercase letters, lowercase letters, numbers, and two special characters (+ and /). This character set is specifically chosen to be universally compatible with most text-based systems, ensuring that the data remains intact and uncorrupted during transit. The encoded output, a string of these characters, can then be safely embedded in text-based formats like HTML, XML, or JSON, or transmitted through email systems without the risk of being misinterpreted as control characters.

The technical process of Base64 encoding is a fascinating example of data manipulation for compatibility. It begins by taking a stream of binary data and dividing it into 3-byte (24-bit) groups. Each of these 24-bit groups is then further divided into four 6-bit segments. Each 6-bit segment can represent a value from 0 to 63, which corresponds to an index in the Base64 character set. The character at that index is then used to represent the 6-bit segment. If the original binary data is not a multiple of 3 bytes, padding is added to the end of the encoded output. This is done by adding one or two '=' characters to the end of the string, indicating that the original data was one or two bytes short of a full 3-byte group. This padding ensures that the encoded data can be correctly decoded back to its original binary form without any loss of information, making Base64 a reliable and reversible process.

The importance of Base64 encoding extends far beyond simple data transmission. It plays a critical role in various web technologies and security protocols. For instance, it is commonly used to embed images directly into HTML or CSS files, reducing the number of HTTP requests needed to render a page and improving performance. In the realm of security, Base64 is often used to encode credentials for HTTP basic authentication, providing a simple way to transmit usernames and passwords. It is also a fundamental component of many data URI schemes, allowing for the inclusion of data in-line in web pages. Furthermore, Base64 is used in the creation of digital signatures and certificates, where it is used to encode the binary data of the signature or certificate into a text format that can be easily stored and transmitted. Its versatility and reliability have made it an indispensable tool for developers and system administrators working with a wide range of applications and protocols.

Worked example

Embedding a 9,216-byte PNG icon in a stylesheet as a data URI

A developer has an icon PNG of 9,216 bytes that is used on one button and wants it inside the CSS file so the button paints without a second network request, and needs to know how much the stylesheet grows and what prefix to use.

  1. Open the Encode tab and press Load file to encode, then choose the 9,216-byte PNG. The file card shows the name, 9.0 KB and the word encoded.
  2. The encoder reads the bytes with the File API in 24 KB chunks, so no single call has to turn the whole file into one huge string, and nothing is uploaded.
  3. The output is 12,288 characters, because Base64 turns every 3 bytes into 4 characters: 9,216 divided by 3 is 3,072, times 4 is 12,288. The same arithmetic was checked against a 12,345-byte file, which the encoder returns as exactly 16,460 characters.
  4. That is 33.3 percent more data than the original file, and 12,288 characters is well under the 200,000 character display limit, so the value is shown in the output box rather than only offered as a download.
  5. Press Download to save the value, or Copy to put it on the clipboard. A file encode is offered as a download named after the original with .b64 appended, so icon.png becomes icon.png.b64.
  6. Paste it into the rule with the prefix: background-image: url("data:image/png;base64,PASTE"), where PASTE stands for the 12,288 characters. The prefix data:image/png;base64, is 22 characters, so the declaration carries 12,310 characters of payload.
  7. The stylesheet grows by roughly 12 KB and the button saves one HTTP request. Base64 is an encoding, not encryption: anyone who opens the CSS file, or the browser cache, can read the PNG bytes straight back out.

Result: A 9,216-byte PNG becomes 12,288 Base64 characters, 12,310 with the data:image/png;base64, prefix, a 33.3 percent size increase that removes one request. The same tool decodes any of those values back to the exact bytes, and the whole round trip stays in the browser tab.

How to use Base64 Encoder/Decoder

  1. Enter text or Base64
  2. Click Encode or Decode
  3. View result
  4. Copy to clipboard

Common mistakes

Treating Base64 as encryption, or as a way to hide something so that other people cannot read it.

Base64 is a reversible encoding that any decoder undoes instantly, and this tool decodes a value in one click. Anything written as Base64 in a configuration file, a URL or a database column is readable by whoever sees it, including credentials and personal data. Use file-encryptor when a file must be protected and a password manager when a secret must be stored.

Pasting a complete data URI into the decode box.

The decoder wants the Base64 payload on its own. A value that starts with data:image/png;base64, fails validation because of the colon, the semicolon, the slash and the comma, which are not part of any Base64 alphabet. Paste only what follows the comma.

Assuming that a decoded JWT payload proves anything about the token.

The tool recognises three dot-separated base64url segments and decodes the middle one as JSON, and it says plainly that the header and the signature are separate segments. It does not verify the signature, so the claims are only readable, not trustworthy: anybody can craft a token with any payload. Verify the token with the issuing service or a JWT library.

Putting a standard-alphabet Base64 value into a URL, a query parameter or a filename.

The standard alphabet contains plus and slash, which URLs and file systems reinterpret, and the padding equals signs are awkward in query strings. Switch on the URL-safe option, which emits minus and underscore and drops the padding, and remember that the decoder turns URL-safe mode on automatically when it sees a minus or an underscore in the input.

Features

Limits worth knowing

When to use it

Practical tips

Why use this tool

When this is not the right tool

Frequently asked questions

What is Base64?

Encoding converting binary to ASCII using 64 characters.

Why use it?

Safely transmit binary through text-only channels.

Is it encryption?

No, encoding only. Easily decoded by anyone.

Size increase?

About 33% larger than original.

Related tools in Developer Tools

Further reading

Base64 Encoder/Decoder: Encode and Decode Base64 Online

Encode text to Base64 or decode Base64 to text. Essential for developers working with APIs, data URIs, and encoded content.