Skip to content
NeedToConvert

Base64 Encoder and Decoder

Turn text or any file into Base64, or turn Base64 back into the original bytes, without uploading anything.

  • Free
  • Private
  • No sign-up
Runs on your device. Nothing you enter is uploaded.

Base64 shows up wherever binary data has to travel through a channel built for text: an image inlined in CSS, an attachment inside an email, a certificate pasted into a config file, a token in an HTTP header. This tool covers the three jobs developers actually need: encoding and decoding text, turning a file into Base64 or a data URL, and rebuilding a file from a Base64 string.

Everything happens in your browser tab. The text you type and the files you choose are processed locally with the browser's own Base64 functions, so API keys, private certificates and customer documents never leave your machine.

What Base64 is, and what it is not

Base64 is an encoding defined in RFC 4648. It takes bytes three at a time (24 bits) and writes them as four characters from a 64-symbol alphabet: A to Z, a to z, 0 to 9, plus + and /. When the input length is not a multiple of three, one or two = signs pad the end. The word Hi, for example, is the two bytes 0x48 0x69 and encodes to SGk=. Because four characters carry three bytes, Base64 output is always about 33 percent larger than the input.

Base64 is not encryption and not compression. There is no key: anyone who sees a Base64 string can decode it in a second, exactly as this page does. Kubernetes Secrets and HTTP Basic authentication headers are Base64 encoded, which is why they still need access control and HTTPS. If you need to hide data, encrypt it; if you need to check that data has not changed, hash it.

Where Base64 is used

Inlining small images and fonts

A data URL such as data:image/png;base64,... lets you embed an icon directly in HTML, CSS or an email template, saving a separate request. It works best for files of a few kilobytes; larger assets are better served as normal files because the encoded copy is a third bigger and cannot be cached on its own.

Binary data inside JSON, XML or YAML

These formats cannot hold raw bytes, so APIs commonly send file contents, signatures and keys as Base64 strings. Encoding a test file here gives you a value to paste into a request body or a fixture.

Reading tokens and config values

JSON Web Tokens use the URL-safe Base64 variant for their header and payload, and many cloud consoles show secrets in Base64. Decoding the value shows what it really contains, which is often the fastest way to debug an authentication problem.

How the three modes work

In Text mode, encoding first converts your text to UTF-8 bytes, so accented letters, Arabic script and emoji round-trip correctly. The URL-safe switch swaps + for - and / for _ and removes the trailing = padding, the form used in URLs and JWTs. Decoding accepts either alphabet, ignores spaces and line breaks, tolerates missing padding and strips the data:...;base64, header if you paste a whole data URL. A data URL without ;base64 holds plain text rather than Base64, and the tool tells you so. If the decoded bytes are not valid UTF-8 text, the tool says so instead of showing garbage.

File to Base64 reads the file you choose and offers two outputs: Data URL, which includes the file's MIME type and is ready for a src attribute, or Base64 only, the bare string, optionally URL-safe. Base64 to file decodes what you paste, detects the MIME type when the input is a data URL, and downloads the bytes under the file name and type you set.

How to use this tool

  1. Pick a Mode: Text, File to Base64 or Base64 to file.
  2. For text, choose Encode or Decode under Direction and type or paste into the input box; the result updates as you type. Turn on URL-safe if the output goes into a URL or a token.
  3. For a file, press Choose a file, then select Data URL or Base64 only under Output.
  4. To rebuild a file, paste the Base64 or data URL, set the file name with the right extension, and press Download file.

Limitations

  • Files up to 50 MB can be encoded. Very large outputs are shown as a preview of the first 20,000 characters, but Copy and Download always contain the full string.
  • Text mode decodes to UTF-8 only. Base64 that holds binary data or text in another encoding, such as Windows-1252, must go through Base64 to file instead.
  • When the pasted Base64 is not a data URL, the file type cannot be detected and defaults to application/octet-stream, so type a name with the correct extension.

Frequently asked questions

Is Base64 a form of encryption?

No. It is a reversible encoding with no secret involved. Anyone can decode it, so never treat Base64 as protection for passwords, keys or personal data.

Why is the Base64 version bigger than my file?

Every 3 bytes become 4 characters, so the output is roughly 4/3 of the original size, plus up to two padding characters. A 30 KB image becomes about 40 KB of text.

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

Standard Base64 uses + and /, which have special meanings in URLs. The URL-safe alphabet from RFC 4648 uses - and _ instead and usually drops the = padding. This decoder reads both forms.

Why does decoding say the result is not readable text?

The input is valid Base64, but the bytes inside are not UTF-8 text. It is probably an image, a PDF or compressed data. Switch to Base64 to file and download it.