Base64 Encoder & Decoder

Encode text or files to Base64, or decode Base64 back into text, images and other files. It handles URL-safe Base64 and data: URIs, and everything runs in your browser.

  • Every character counts
  • URL-safe and data: URIs
  • Text, images and files

Waiting for input

Text or file

Base64

The result appears here.

Advertisement

What it does

Type or paste text and the Base64 appears as you go, or choose a file to encode. In the other direction, paste Base64 or a data: URI and the tool works out what is inside. Text is shown exactly as it was encoded. Anything else, such as an image, a PDF or a ZIP file, is recognised from its first bytes, previewed if it is an image, and offered as a download.

Exactly what you typed

Base64 encodes bytes, so every character counts, including spaces and line breaks at the start or end. "hello" and "hello" followed by a new line produce different results. This tool encodes your input exactly and does not trim it, and when decoding, it shows the text exactly as it was, without reformatting it. If the decoded text is JSON, a Format JSON button lets you pretty-print it while keeping the exact version one click away.

Standard, URL-safe and padding

Standard Base64 uses + and / and ends with = padding. The URL-safe variant uses - and _ instead, because + and / have special meanings in addresses and file names; it often drops the padding too. JSON Web Tokens are built from this variant. When you encode, you choose which one you want. When you decode, the tool accepts both, with or without padding, and ignores line breaks, so a block copied from an email or a certificate works as it is.

Files and data URIs

Encoding a file gives you text you can paste into JSON, an email or a config file. For a file with a known type you can copy it as a data: URI, such as data:image/png;base64,..., which lets you embed a small image directly in HTML or CSS. Keep that for tiny files: Base64 is about a third larger than the original, and an embedded image cannot be cached on its own.

Base64 is not security

Because anyone can decode Base64 without a key, treat anything encoded this way as readable. Basic authentication headers, the middle part of a JWT and many API tokens are only Base64, not protected. If something must stay private, it needs real encryption.

Frequently asked questions

Is Base64 a way to keep data secret?

No. Base64 is an encoding, not encryption. Anyone can decode it instantly with no key, so never use it to hide passwords or personal data.

Is my data uploaded?

No. Encoding and decoding happen in your browser. Text and files never leave your device.

Why does the result end with = signs?

They are padding. Base64 works in groups of three bytes, and padding fills the last group. You can leave it out when you encode, and the decoder accepts input with or without it.

What is URL-safe Base64?

It swaps + and / for - and _ so the result can sit safely in a URL or file name. JSON Web Tokens use it. Tick the URL-safe option to produce it. When decoding, both forms are recognised automatically.

Can I encode an image or another file?

Yes. Choose "Encode a file". For a file with a known type you can also copy the result as a data: URI to embed it in HTML or CSS. The encoded text is about a third larger than the file.

Can I decode an image or a PDF?

Yes. If the decoded bytes are not text, the tool recognises common types such as PNG, JPEG, GIF, WebP, PDF and ZIP, shows a preview for images, and lets you download the file.

Why is my decoded text garbled?

Text is read as UTF-8. If the data was encoded with another character set, or is not text at all, the result will not look right. The tool treats data that is not valid UTF-8 as a file instead of showing noise.

More tools like this

All tools →