Advertisement

Base64 Encode and Decode

Encode or decode Base64 - text, images, PDFs and any file - with URL-safe mode and automatic file-type detection.

Last updated:

Base64 Encoder / Decoder
Text · Image · PDF · File
Encode or decode Base64 in your browser - nothing is uploaded.

How to Encode or Decode Base64

1
Text: type on the left to encode, or paste Base64 on the right to decode
2
Image or file: choose it in File → Base64 and copy the result
3
Base64 → File: paste the string; the type is detected and you can download it

Nothing is uploaded, so it is safe for tokens, keys and private files.

What You Can Do

TaskTabAlso searched as
Encode textText → Encodebase64 encode, text to base64, string to base64
Decode textText → Decodebase64 decode, base64 to text, decode base64 string
Image to Base64File → Base64image to base64, png to base64, jpg to base64
Base64 to imageBase64 → Filebase64 to image, base64 to png, base64 image viewer
Base64 to PDFBase64 → Filebase64 to pdf, decode base64 pdf
URL-safeText + URL-safebase64url encode, base64url decode

What Is Base64?

Base64 vs Base64URL

VariantCharactersPaddingUsed in
Standard+ and /= at the endEmail, data URIs, most APIs
URL-safe (Base64URL)- and _Usually removedJWTs, URLs, file names

Base64 in Code

LanguageEncodeDecode
JavaScript (browser)btoa(str) - ASCII only; use TextEncoder for UTF-8atob(b64)
Node.jsBuffer.from(str).toString("base64")Buffer.from(b64, "base64").toString()
Pythonbase64.b64encode(b"text")base64.b64decode(s)
JavaBase64.getEncoder().encodeToString(bytes)Base64.getDecoder().decode(s)
PHPbase64_encode($s)base64_decode($s)
Linux / Macbase64 file.pngbase64 -d file.txt > out.png

Common Base64 Problems

When Should You Inline Images as Base64?

SituationUse Base64?
Tiny icons under ~4 KBYes - saves an HTTP request
Images in HTML emailsOften blocked - prefer hosted links
Large photosNo - 33% bigger and cannot be cached separately
Files inside JSON APIsYes, for small files
Fonts and SVG in CSSSometimes - SVG can also be URL-encoded instead

Related Tools

Frequently Asked Questions

How do I decode Base64? +

Paste it in the Base64 box; with Live on, the text appears instantly. For images or PDFs use the Base64 → File tab.

How do I convert an image to Base64? +

Open File / Image → Base64, choose the image and copy the result - with or without the data URI prefix.

How do I convert Base64 to an image or PDF? +

Paste the string in Base64 → File. The file type is detected; preview images and download any file.

Is Base64 encryption? +

No. It is a reversible encoding - anyone can decode it. Use encryption for secrets.

What is URL-safe Base64? +

A variant that uses - and _ instead of + and / and drops = padding, so it is safe in URLs and JWTs.

Why is Base64 bigger than the original? +

Every 3 bytes become 4 characters, so the output is about 33% larger.

Does it support emoji and non-English text? +

Yes. Text is encoded as UTF-8.

Are my files uploaded? +

No. Everything is processed in your browser.

About the creator Prajwal Karkera, creator of ToolsFlow

Built and maintained by Prajwal Karkera, a digital product specialist with 8+ years of experience in digital products. Found a problem with this tool? Let us know through the Contact page.
Read more about me →