Encoding

Base64 Encoder & Decoder

Encode and decode Base64 with Unicode and URL-safe support. Great for API tokens and JSON payloads.

Encoding options

0

Characters

0 B

Input size

0 B

Output size

0%

Expansion

Input

Ready

0 characters

Output

0 characters

Ctrl + Enter Transform now ·Ctrl + Shift + X Swap

Base64, explained

What is Base64?

Base64 is an encoding scheme that turns binary data into a safe, portable ASCII string. Every set of three bytes is represented by four characters chosen from a 64-character alphabet — hence the name — which means it can ride along in JSON payloads, HTTP headers, URLs and email without corruption.

It is not compression. A 3-byte group always becomes 4 characters, so Base64 output is about 33% larger than the original. This Encoder/Decoder shows that growth live in the Expansion metric.

How Base64 Works

Under the hood the input is treated as a stream of bytes. Those bytes are grouped three at a time, then re-sliced into four 6-bit values. Each 6-bit value (0–63) maps to one character in the alphabet: A–Z, a–z, 0–9, “+” and “/”.

When the input length is not a multiple of three, the final group is padded with “=” characters. This tool pads correctly and, because it works on UTF-8 bytes, every emoji and non-Latin script survives a full round trip.

  • 3 bytes in → 4 characters out.
  • Padding: zero, one, or two “=” signs at the end.
  • Text is always encoded as UTF-8 before Base64.

Base64 vs Encryption

Base64 is reversible but not secret. Encoding is a fixed, public mapping, so anyone can decode a Base64 string without any key. This makes it perfect for data interchange but useless for security.

Encryption, by contrast, transforms data with a secret key and an algorithm, and is only readable by whoever holds that key. If you need confidentiality, encrypt first and then Base64-encode the ciphertext for safe transport — but never rely on Base64 alone to hide information.

Common API Use Cases

APIs use Base64 constantly. REST and GraphQL bodies carry binary attachments (images, PDFs, icons) as Base64 strings; HTTP Basic authentication sends username:password as a Base64 header; and pagination tokens both in and out are frequently Base64-encoded.

For URLs, the classic alphabet is awkward because “+” and “/” have special meaning. Enable the URL-safe option to swap in “-” and “_” and drop the padding, producing strings that are safe in query strings and path segments.

JWT Payload Encoding

A JSON Web Token is three Base64url-encoded segments separated by dots. The middle segment is the payload — the claims such as sub, role and exp. Decode it here to inspect the claims inside any token you hold.

Paste a JWT payload segment into Decode mode (or Auto detect) to read its contents instantly. When you need a valid token to test with, load a JWT-shaped example and run it through Auto detect.

Frequently asked questions

How do I encode text to Base64?

Select the Encode tab, type or paste your text into the left panel, and the encoded result appears instantly on the right. Press Ctrl+Enter (Cmd+Enter on Mac) to force an immediate transform.

How do I decode a Base64 string?

Select the Decode tab and paste the Base64 string into the input. The tool decodes it as UTF-8 text. You can also choose Auto detect to let the tool decide whether your input needs encoding or decoding.

Does Base64 encoding work with Unicode, emoji, and non-Latin scripts?

Yes. All text is encoded from UTF-8 bytes, so emoji, Chinese, Arabic, Hebrew and accented characters all survive the round trip exactly. Character counts count full Unicode code points rather than code units.

What is URL-safe Base64?

Standard Base64 uses “+” and “/”, which have special meaning in URLs, and trailing “=” padding. URL-safe Base64 replaces “+” with “-” and “/” with “_”, and omits the padding. Toggle the URL-safe option to encode or decode with that alphabet.

How large can the input be?

The transformation engine is built for payloads of 10 MB and beyond. Encoding and decoding run in a single fast pass over the bytes, and the result appears after a short debounce so the page never blocks while you type.

Why is the output bigger than the input?

Every three bytes of input become four Base64 characters, so encoded output is always about 33% larger. The Expansion metric shows the exact percentage for your input — a larger number simply means more source bytes were converted.

Can I upload a file to encode or decode?

Yes. Click 'Upload file' on the input panel and choose a .txt, .json, or .csv file. Its contents are read as UTF-8 text and fed into the transformer, so a whole config file or log can be encoded in one step.

What happens when I click Swap?

Swap moves the current output into the input and flips the mode (Encode becomes Decode and vice versa). It is the fastest way to round-trip: encode a string, swap, and you have the original text back.

Is Base64 the same as encryption?

No. Base64 is merely an encoding — it uses a fixed, public alphabet and can be reversed by anyone. Encrypting requires a secret key and provides confidentiality. You can encrypt then Base64-encode the result for transport, but Base64 alone never hides data.

Is my data sent to a server?

No. Everything — encoding, decoding, metrics and file reads — happens entirely in your browser. Nothing you paste or upload is transmitted, logged, or stored.

Why does decoding report 'Invalid Base64 input'?

Base64 accepts only A–Z, a–z, 0–9, “+” and “/” (or “-” and “_” when URL-safe is enabled), with at most two “=” characters at the very end. The error message points at the exact character and position that breaks the rules.

What are the keyboard shortcuts?

Press Ctrl+Enter (Cmd+Enter on Mac) to transform immediately, and Ctrl+Shift+X to swap the output into the input while flipping the mode.