Base64 Encoder / Decoder

Encode text to Base64 or decode Base64 back to text, with full Unicode support and a URL-safe option. You can also turn any file or image into a Base64 data URI.

  • Unicode (UTF-8) safe
  • URL-safe Base64
  • Runs in your browser

How to use the Base64 Encoder / Decoder tool

  1. Choose a modeUse “Text” to encode or decode strings, or “File to Base64” to convert a file into a data URI.
  2. Enter your dataPaste or type text, or drop a file onto the box.
  3. Encode or decodeClick the button you need. Tick “URL-safe” if the result will be used in a URL or file name.
  4. Copy the resultCopy the output, or swap it back into the input to reverse the operation.

Features

  • UTF-8 awareEmojis, accented letters and non-Latin scripts encode and decode correctly.
  • URL-safe variantUses - and _ instead of + and / and drops padding, as required by JWTs and many APIs.
  • Files to data URIsEmbed small images, icons and fonts directly in HTML, CSS or JSON.
  • Helpful errorsInvalid characters and binary data are detected and explained.
  • PrivateTokens and secrets never leave your browser.

What is Base64?

Base64 is a way of representing binary data using only 64 printable characters: A–Z, a–z, 0–9, plus + and /, with = used for padding. It was designed so that any data, including images and other binary files, can travel safely through systems that only handle text, such as email, JSON, XML and URLs.

Base64 is an encoding, not encryption. Anyone can decode it, so it must never be used to protect passwords or secrets.

How Base64 works

The encoder takes the input three bytes (24 bits) at a time and splits them into four groups of 6 bits. Each 6-bit value (0–63) is mapped to one of the 64 characters. Because 3 bytes become 4 characters, Base64 output is about 33% larger than the original. When the input length is not a multiple of three, one or two = characters are added as padding.

Example: the text Hi! is the bytes 72, 105, 33, which encode to SGkh.

Common uses

  • Data URIs: embedding small images or fonts directly in HTML or CSS, such as data:image/png;base64,iVBOR…, which saves an extra network request.
  • APIs and JSON: sending file contents or binary data inside JSON payloads.
  • Email attachments: MIME encodes attachments in Base64.
  • Authentication headers: HTTP Basic Auth sends username:password Base64-encoded, which is why it must only be used over HTTPS.
  • JSON Web Tokens (JWT): the header and payload are Base64URL-encoded.

Standard vs URL-safe Base64

The + and / characters have special meanings in URLs and file paths, and = is used in query strings. The URL-safe variant (Base64URL) replaces + with - and / with _, and usually omits the padding. The decoder on this page accepts both variants automatically.

When not to use data URIs

Inlining images as Base64 is handy for tiny icons, but for larger images it makes HTML and CSS files bigger, prevents the browser from caching the image separately and can slow down page rendering. As a rule of thumb, keep data URIs for images under a few kilobytes.

Frequently asked questions

Is Base64 encryption?
No. Base64 is a reversible encoding that anyone can decode. Never use it to hide passwords or sensitive information.
Why is my Base64 output longer than the input?
Every 3 bytes of input become 4 characters of output, so Base64 is about 33% larger than the original data.
Does it support emojis and non-English text?
Yes. Text is converted to UTF-8 before encoding, so any language and emojis work correctly.
What is URL-safe Base64?
A variant that uses - and _ instead of + and / and drops the = padding, so the result can be used in URLs and file names. It is used by JWTs and many web APIs.
Is my data sent to a server?
No. Encoding and decoding happen entirely in your browser.