Free Base64 Encoder & Decoder

Encode text or images to Base64 โ€” or decode Base64 strings โ€” entirely in your browser. No data leaves your device.

Advertisement ยท 728ร—90

Enter text or upload an image to see the Base64 output.

Advertisement ยท 300ร—250

What Is Base64?

Base64 is a binary-to-text encoding scheme that represents binary data โ€” such as images, audio files, and other binary content โ€” using only 64 printable ASCII characters. The characters used are Aโ€“Z (26 characters), aโ€“z (26 characters), 0โ€“9 (10 characters), and two additional characters that vary by variant: + and / in the standard Base64 alphabet, or - and _ in the URL-safe variant (Base64url). Padding characters (=) are used to ensure the encoded output length is always a multiple of four characters.

The name "Base64" comes from the encoding base: 64 possible characters per position, which requires 6 bits of information to encode each character (2โถ = 64). Since each original byte is 8 bits, every 3 bytes (24 bits) of input are encoded as 4 Base64 characters (24 รท 6 = 4). This means Base64-encoded data is approximately 33% larger than the original binary data โ€” a tradeoff accepted because it makes binary data safe to include in text-based systems like email, JSON, XML, CSS, and HTML.

When Do Developers Use Base64?

Base64 encoding appears throughout modern web development and software engineering. Here are the most common scenarios:

  • Data URIs in HTML and CSS: Small images, fonts, and icons are commonly inlined into HTML or CSS as Base64-encoded data URIs. This eliminates additional HTTP requests: <img src="data:image/png;base64,iVBORw0KGgo...">. Useful for small images that would otherwise require a separate request, though generally not recommended for images over a few kilobytes.
  • JSON and XML payloads: When binary data needs to be included in a JSON or XML document, Base64 is the standard approach. REST APIs commonly encode file uploads, thumbnails, certificates, and binary blobs as Base64 strings within JSON bodies.
  • Email attachments (MIME): Email was originally designed only for ASCII text. The MIME standard specifies that binary attachments โ€” images, PDFs, Word documents โ€” must be Base64-encoded before being included in email messages. Your email client handles this transparently when you attach files.
  • HTTP Basic Authentication: The HTTP Basic Auth header encodes credentials as Base64(username:password). While trivially decodable (it is not encryption), it allows credentials to be safely included in headers that only support ASCII characters. Always use HTTPS with Basic Auth.
  • Storing binary data in databases: Relational databases store data as text or binary columns. Base64 is sometimes used to store binary data in text columns, though dedicated binary column types (BLOB, BYTEA) are generally preferred.
  • Cryptographic keys and certificates: PEM-formatted SSL/TLS certificates and private keys are Base64-encoded DER certificates wrapped in header/footer lines. This allows cryptographic binary data to be pasted into text editors and configuration files.

Base64 vs Base64url

The standard Base64 alphabet uses + and /, which have special meanings in URLs and query strings. To safely include Base64-encoded data in URLs without percent-encoding, the URL-safe variant (Base64url) replaces + with - and / with _. Base64url is used in JSON Web Tokens (JWTs), OAuth tokens, and URL-safe identifiers. This tool uses standard Base64 (not Base64url).

Is Base64 Encryption?

No. Base64 is encoding, not encryption. It transforms binary data into a text-safe format using a deterministic, reversible, publicly-known algorithm with no key involved. Anyone with the encoded string can decode it instantly โ€” there is no secret. Base64 does not provide any security or confidentiality. Do not use it to obscure passwords, API keys, or sensitive data in client-side code or publicly accessible files, as it provides zero protection against anyone who looks at the encoded string.

Frequently Asked Questions

No. All encoding and decoding is performed entirely in your browser using JavaScript's built-in btoa() and atob() functions for text, and the FileReader API for images. Your text and images never leave your device and are not transmitted, logged, or stored anywhere on our servers.

Base64 encodes 3 bytes at a time into 4 characters. When the input is not divisible by 3 bytes, padding characters (=) are appended to make the encoded output a multiple of 4 characters. One = means the last group had 2 bytes, and == means the last group had 1 byte. Some implementations omit padding for brevity โ€” both padded and unpadded Base64 decode to the same binary data.

Yes, this tool can encode images of any size that your browser can handle. However, inlining large images as Base64 data URIs in HTML or CSS is generally not recommended, as it significantly increases file size (by ~33%) and can hurt page load performance. Data URIs also bypass the browser's cache โ€” every page load re-parses the encoded string. Base64 data URIs are best suited for small images under 5โ€“10KB, such as icons, logos, and UI elements.

The most common cause is a URL-safe Base64 string (using - and _) being decoded with the standard Base64 alphabet. Standard Base64 uses + and /, while Base64url replaces them with - and _. If your Base64 string contains hyphens or underscores, replace them with + and / respectively before decoding. Also ensure there are no line breaks or spaces in the input โ€” some Base64 encoders insert line breaks every 76 characters (MIME-standard), which must be removed before decoding.

The browser's built-in btoa() function only works with ASCII characters. To encode Unicode text (which includes emojis, non-Latin characters, accented letters), the text must first be encoded as UTF-8 bytes, then Base64-encoded. This tool handles this automatically for text input. In code: btoa(unescape(encodeURIComponent(text))) or using a TextEncoder to get UTF-8 bytes before Base64 encoding.

A data URI is a URI scheme that allows embedding small files directly in HTML or CSS, following the format: data:[mediatype][;base64],data. For a PNG image, it looks like: data:image/png;base64,iVBORw0KGgo.... This can be used as the src attribute of an <img> tag or as a CSS background-image URL. The image file is effectively inlined in the HTML/CSS document, eliminating an HTTP request โ€” useful for critical above-the-fold images or icon fonts.

Related Free Tools

Need a custom tool built for your business?

Get a Free Quote