EN FR

Base64 Encoder / Decoder

Instant text ↔ Base64 conversion. URL-safe mode, image to Data URL, auto-detect.
Plain text
Base64
Replaces +- and /_, removes = padding — used in JWT, OAuth
Image → Base64 Data URL
Drag & drop an image, or click to select
PNG, JPG, GIF, WebP, SVG — any size
Image preview

What is Base64 encoding?

Base64 is a binary-to-text encoding scheme that represents binary data using a set of 64 printable ASCII characters (A–Z, a–z, 0–9, +, /). It is used to safely transmit binary data over channels that only support text, such as email, JSON, XML, or HTTP headers.

Important: Base64 is not encryption. It is a fully reversible encoding with no key or secret. Never use it to secure sensitive data.

Common use cases

  • Inline images in CSS/HTMLdata:image/png;base64,... embeds images directly without a separate HTTP request.
  • Email attachments — MIME encoding uses Base64 to attach binary files to text-based emails.
  • JWT tokens — The header and payload parts of a JWT are Base64url-encoded JSON objects.
  • Binary data in JSON APIs — When you need to send files or images in a JSON body.
  • Basic Auth headers — HTTP Basic Authentication encodes username:password in Base64.

Standard Base64 vs URL-safe Base64 (Base64url)

Standard Base64 uses +, /, and = (padding). These characters are reserved in URLs, which causes issues when Base64 strings appear in query parameters, JWT tokens, or filenames.

Base64url solves this by replacing + with - and / with _, and omitting the = padding. It is the variant used in JWT, OAuth 2.0 PKCE, and most modern APIs. Use the toggle above to switch between the two modes.

Size impact

Base64 encoding increases data size by approximately 33%. Every 3 bytes of binary input become 4 ASCII characters. For inline images, this tradeoff is often worth eliminating an HTTP request — but for large assets it is usually better to serve the original file.

Frequently Asked Questions

Is Base64 encryption?

No. Base64 is a reversible encoding with no key or password. Anyone who has a Base64-encoded string can decode it instantly. Do not use it to protect sensitive data — use proper encryption (AES, RSA) instead.

What is the difference between Base64 and Base64url?

Base64url replaces the two URL-unsafe characters: + becomes -, and / becomes _. The = padding is also removed. The result can safely appear in URLs, filenames, and HTTP headers. JWTs always use Base64url for their header and payload parts.

How do I convert an image to Base64 in my browser?

Use the drop zone on this page. Drag and drop an image or click to select one — the full Data URL is generated immediately, ready to use in your HTML or CSS. No upload to any server occurs.

How do I encode Base64 in JavaScript?

Use btoa(str) for plain ASCII strings, or for Unicode: btoa(unescape(encodeURIComponent(str))). For files, use the FileReader API with readAsDataURL(). To decode: atob(base64str).

How do I encode Base64 in Python?

Use the base64 module: import base64; base64.b64encode(b"Hello"). For URL-safe: base64.urlsafe_b64encode(b"Hello"). To decode: base64.b64decode(encoded).

Why does Base64 sometimes end with == ?

Base64 encodes 3 bytes at a time into 4 characters. When the input length is not a multiple of 3, padding characters = are added to make the output length a multiple of 4. One = means 1 byte of padding was needed; two == means 2 bytes. Base64url omits this padding entirely.

Is my data sent to a server?

No. All encoding, decoding, and image processing happens entirely in your browser via JavaScript. Nothing you paste or upload ever leaves your machine.

Other useful developer tools