X Xerobit

Base64 Decoder and Encoder

Free online base64 decoder and encoder. Paste a base64 string to decode it to text, or type any text to encode it to base64 — instantly. Runs entirely in your browser, your data never leaves your device. Supports URL-safe variant, file encoding, and proper UTF-8 handling.

Shortcuts: Ctrl/⌘ + Enter re-run · Ctrl/⌘ + Shift + C copy

Base64 decoder — quick reference

The most common task: you have a base64 string and need to see what it says. Paste it in with Decode mode selected (or leave it on Auto) and the decoded text appears immediately. For encoding, switch to Encode, type your text, and copy the output.

Classic example — encoding "Hello":

Input:  Hello
Output: SGVsbG8=

Decoding back:

Input:  SGVsbG8=
Output: Hello

Each group of 3 bytes (24 bits) in the source becomes 4 base64 characters (6 bits each). "Hello" is 5 bytes, which expands to 8 base64 characters with one = padding character. Try it with the decoder above — paste SGVsbG8= and click Decode.

More examples to try in the base64 decoder:

How to use the base64 encoder decoder

  1. Pick a mode: Encode (text → Base64), Decode (Base64 → text), or Auto (detects from input).
  2. Paste into the left textbox. Processing runs automatically after 200ms.
  3. Toggle options as needed: URL-safe (-_ instead of +/), No padding (strip trailing =), Wrap 76 (MIME-style line wrapping).
  4. For files, click Upload file (up to 10MB). The output is a full data: URL ready to paste into HTML or CSS.
  5. Copy with the Copy button or Ctrl/⌘ + Shift + C.

What is base64 encoding?

Base64 encoding is a method of representing binary data using only 64 printable ASCII characters: A–Z, a–z, 0–9, +, and /, with = used for padding. It's defined in RFC 4648. The encoded output is about 33% larger than the original because every 3 bytes of input (24 bits) become 4 characters of output (6 bits per character).

The name "base64" comes from the fact that the encoding uses 64 distinct characters as its alphabet. This contrasts with hexadecimal (base16, which doubles file size) or raw binary. Base64 strikes the best balance between compactness and compatibility with text-only systems.

Base64 is not encryption. It's a fully reversible encoding — anyone with a base64 decoder (including this free online tool) can decode it back to the original in seconds. Use it for transport, not secrecy. If you need actual security, use cryptographic hashing or AES encryption.

URL-safe Base64 vs standard Base64

Standard Base64 uses + and /, which have special meaning in URLs and filenames. URL-safe Base64 (RFC 4648 §5) replaces them with - and _. It's used in JWTs, OAuth tokens, and most modern web APIs. Use the URL-safe option whenever the output needs to survive a URL, filename, or identifier.

Padding (=) is often omitted in URL-safe Base64 because its length information is implicit. The No padding option strips trailing = characters. This tool re-pads automatically when decoding, so unpadded input works fine.

Common base64 use cases

Base64 encoding appears throughout modern web development wherever binary data must cross a text-only boundary. Here are the four most common scenarios:

Embedding images and assets as data URLs

HTML and CSS support data: URLs that contain the entire file as base64. A small icon encoded as data:image/png;base64,iVBORw0KGgo... in a <img> or CSS background-image eliminates a separate HTTP request. Best for images under 10KB — beyond that, HTTP caching wins.

JWT tokens and OAuth

Every JSON Web Token is three base64url-encoded segments separated by dots: header.payload.signature. The header and payload are base64-decoded JSON objects. Using this free JWT decoder you can inspect any JWT — but you can also decode the individual segments right here in the base64 decoder by pasting each part separately.

API authentication headers

HTTP Basic Authentication encodes credentials as base64(username:password) and sends them in an Authorization: Basic ... header. This is encoding, not encryption — anyone who intercepts the header can decode it. Always use HTTPS with Basic Auth.

Binary data in JSON payloads

JSON only supports text. When an API needs to transfer a file, image, certificate, or any binary blob inside a JSON response, base64 encoding is the standard approach. The receiver runs it through a base64 decoder to recover the original bytes.

When not to use base64:

Common errors and what they mean

"Invalid character in Base64 string"

Your input contains a character outside the Base64 alphabet. The usual suspects: a stray space, a newline in the middle, a URL-safe string being decoded in standard mode (switch URL-safe on), or unescaped + characters that became spaces during URL transport.

"Length is not a multiple of 4"

Base64 must be padded to a multiple of 4 characters. This tool re-pads automatically, but if you see the error elsewhere (e.g., in Python's base64.b64decode), add = until the length is a multiple of 4, or use urlsafe_b64decode variants that tolerate missing padding.

Garbled decoded output

Usually a character-encoding mismatch. This tool decodes as UTF-8. If your input was originally in Latin-1, Windows-1252, or another encoding, you'll get mojibake. Copy the decoded bytes into a hex viewer or re-encode the original source as UTF-8 before encoding.

UTF-8 vs Latin-1 gotcha

The browser's built-in btoa() and atob() only work on Latin-1 (single-byte) strings and will throw on characters outside that range — including most emoji, CJK characters, and accented Latin beyond ISO-8859-1. This tool uses TextEncoder/TextDecoder for proper UTF-8 support, so strings like "🦊 résumé 日本" encode and decode correctly.

Frequently asked questions

What is a base64 decoder and when do I need one?

A base64 decoder converts base64-encoded text back to its original form — plain text, binary data, images, or any other content that was encoded. You need a base64 decoder when you encounter a base64 string and want to read what it contains: inspecting a JWT token, debugging an API response, extracting an image from a data URL, or reading credentials encoded in an Authorization header. This online base64 decoder handles all of these cases directly in your browser.

Is the base64 encoder and decoder really client-side?

Yes. All encoding, decoding, and file processing happens in JavaScript running in your browser. You can verify this by opening DevTools → Network and watching: no request is sent when you click Encode or upload a file. You can also disconnect from the internet after the page loads and the tool keeps working.

Can I encode a whole file to Base64?

Yes — click Upload file. The output is a full data: URL (including the detected MIME type), which you can paste directly into <img src="..."> or url(...) in CSS. File size cap is 10MB to keep the UI responsive; beyond that, browsers get slow and most real use cases want a proper asset URL anyway.

How do I convert Base64 back into a downloadable file?

Paste the Base64 (or full data URL) into the input, select Decode, and the decoded bytes will be interpreted as UTF-8 text. To reconstruct a binary file, use a language-native base64 decoder (Python base64.b64decode, Node Buffer.from(s, 'base64')) and write the bytes to disk. A browser-native "Download decoded file" is on the roadmap.

Does this tool support Base64 URL-safe JWT tokens?

Yes — enable URL-safe and No padding, then decode each of the three dot-separated sections of a JWT. For a dedicated token-parsing experience with algorithm info and claim pretty-printing, see the upcoming JWT Decoder.

Why is the Base64 output 33% larger than the input?

Base64 encodes every 3 bytes (24 bits) of input as 4 characters (32 bits — one 6-bit value per char). That's a fixed 4/3 expansion, plus up to 2 padding characters at the end. If size matters (SMS, QR codes), consider Base85 or Base91 — or better, don't encode in the first place.

Is this tool RFC 4648 compliant?

Yes. Both the standard alphabet (§4) and the URL-safe alphabet (§5) are implemented faithfully. Padding is preserved by default and stripped only when you ask for it. Line wrapping uses the MIME standard 76-character width (§3.1) when enabled.

Related tools

Related articles

Pillar

Part of Encoding & Crypto — Base64, URL, JWT, hashes, UUID, QR, password.


Written and maintained by Mian Ali Khalid. Last updated 2026-05-12.