Base64 Encoder / Decoder

Encode text to Base64 or decode Base64 back to plain text — instantly, in your browser

Invalid Base64 string

What Is Base64?

Base64 is a binary-to-text encoding scheme that converts data into a string of 64 printable ASCII characters. It is used extensively in web development: embedding images in HTML/CSS as data URIs, encoding authentication credentials in HTTP headers, and transmitting binary data through JSON APIs.

The encoded output is always larger than the input — approximately 33% larger — because every 3 bytes of input become 4 characters of output. For URL-safe Base64, the + and / characters are replaced with - and _ so the string can appear in URLs without percent-encoding. This variant is used in JWT tokens and many OAuth implementations.

How Base64 Encoding Works

Base64 works in groups of 3 bytes (24 bits) at a time. Those 24 bits are split into four 6-bit chunks, and each 6-bit chunk (a value from 0–63) is mapped to one of 64 characters (A–Z, a–z, 0–9, + and /). That's where the name comes from. If the input isn't a multiple of 3 bytes, = padding characters are added at the end to fill out the last group.

Worked example: the text "Hi!" is 3 bytes (72, 105, 33 in ASCII). Encoded to Base64, it becomes SGkh — 4 characters for 3 bytes, matching the expected 33% size increase.

Where Base64 Is Used

  • Data URIs — embedding small images directly in CSS or HTML (data:image/png;base64,...) to avoid an extra HTTP request.
  • Email attachments (MIME) — email was designed for text, so binary attachments are Base64-encoded before sending.
  • JWT tokens — the header and payload of a JSON Web Token are URL-safe Base64-encoded JSON.
  • Basic HTTP authentication — the Authorization: Basic header encodes "username:password" as Base64 (not encrypted — only use over HTTPS).

Frequently Asked Questions

Base64 encodes binary data as printable ASCII text (64 characters: A–Z, a–z, 0–9, +, /). Used in email attachments, data URIs, and API payloads to safely pass binary through text-only systems.
Click "Decode", paste your Base64 string in the input box. The decoded text appears instantly. If the input isn't valid Base64, you'll see an error.
URL-safe Base64 swaps + → - and / → _ so the encoded string can appear in URLs without percent-encoding. JWT tokens use this variant.
No. Base64 is encoding, not encryption. Anyone can decode it without a key. Never use it to protect sensitive data. Use proper encryption (AES, RSA) for security.
Base64 processes input in groups of 3 bytes. If the last group has only 1 or 2 bytes, = padding characters fill out the remainder so the output length is always a multiple of 4. URL-safe Base64 often omits padding since it isn't required for decoding.

Advertisement