Base64 Decode & Encode

Decode and encode Base64 text and files, UTF-8 safe, with decoded files ready to download.

Base64 Decode and Encode Online: Text and Files, UTF-8 Safe

Paste a string with Decode text or file selected and the Base64 decoder shows the text as you type; switch to Encode text or file and the Base64 encoder converts whatever you type. Binary data has its own path: Choose file encodes any file, and Decode and download file turns a Base64 string back into a file whose type, such as PDF, PNG, JPEG or ZIP, is detected from its first bytes.

Decode Base64

Paste a Base64 string and the decoded text appears immediately. The decoder handles UTF-8, so accented letters, other alphabets and emoji come back intact, which the browser's older atob() function alone cannot do.

If the result is not readable text, the data is probably a file. Use "Decode and download file": the decoder checks the first bytes, recognises common formats (%PDF for PDF, \x89PNG for PNG, FF D8 FF for JPEG, GIF8 for GIF, PK for ZIP-based formats) and saves the file with the right extension.

The status line under the button says what was found, for example Decoded 48,213 bytes as image/webp. Detection covers more than the formats above, including WebP, AVIF, HEIC, MP4, MP3, gzip, 7z and WOFF2, but only PDF, PNG, JPEG, GIF and ZIP get their extension added for you. For anything else, type the full name, such as photo.webp, into Download filename first, or the file is saved as decoded.bin. A text result sprinkled with � characters is the other sign that the string holds a file rather than text.

SGVsbG8sIERldlRvb2xHcmlkIQ==      ->  Hello, DevToolGrid!
Y2Fmw6k=                          ->  café
JVBERi0xLjcK...                   ->  a PDF file (starts with %PDF)
iVBORw0KGgo...                    ->  a PNG image

Encode text or files to Base64

Type or paste text to get its Base64 form. The text is converted to UTF-8 bytes first, so the result matches what servers and other languages produce for the same string. To encode a file, such as an image for a data URI, a certificate or a PDF for an API request, click Choose file. It is read locally and encoded without any upload.

Base64 output is about a third larger than the input: every 3 bytes become 4 characters. A 30 KB image becomes roughly 40 KB of Base64.

How Base64 works

Base64 represents binary data with 64 printable characters, A–Z, a–z, 0–9, + and /, so it can travel through systems that only handle text: JSON, email, HTTP headers, XML and environment variables. It splits the input into groups of 3 bytes (24 bits) and writes each 6-bit piece as one character. When the input length is not a multiple of 3, one or two = signs pad the end.

Base64 is an encoding, not encryption. Anyone can decode it, so "Base64 decrypt" simply means decoding. Never use it to protect passwords or secrets; it only makes data safe to transport as text.

Input the decoder fixes for you

Real-world Base64 is often not quite standard, so the decoder normalises the input before decoding. URL-safe Base64 (Base64url), used in JWTs and many web tokens, has - and _ instead of + and /; they are converted back. Missing = padding is added. A data:image/png;base64, prefix is removed, and its MIME type is used for the downloaded file. Spaces and line breaks from emails, PEM files or terminals are ignored.

eyJzdWIiOiIxIn0                   Base64url, no padding     ->  {"sub":"1"}
data:text/plain;base64,Y2Fmw6k=   data URI                  ->  café
SGVs
bG8=                              wrapped across lines      ->  Hello

One case cannot be repaired automatically: a Base64 value that passed through a URL without being encoded, where each + became a space. Removing the spaces then produces different bytes, so the result looks garbled. Put the + signs back, or encode the value properly with encodeURIComponent next time.

Base64 on the command line and in code

printf '%s' 'Hello' | base64          # SGVsbG8=   (use printf: echo adds a newline)
printf '%s' 'SGVsbG8=' | base64 -d    # Hello
base64 -w0 image.png                  # GNU: single line, no wrapping at 76 chars

btoa(String.fromCharCode(...new TextEncoder().encode(text)))   // browser, UTF-8 safe
Buffer.from(text, 'utf8').toString('base64')                   // Node.js
base64.b64encode(text.encode('utf-8'))                         # Python

Secrets stay on this page

Base64 is often all that stands between a credential and plain view: a Basic authentication header copied from a HAR file, a value from a Kubernetes Secret, a service-account key stored in a CI variable. Decoding here runs in JavaScript on the page, and nothing you paste or select is sent to a server or stored, so you can check what a secret contains without leaking it in the process.

Frequently asked questions

How do I decode Base64?

Select Decode text or file and paste the Base64 string. Readable text appears immediately; for binary data, click Decode and download file to save it with the detected file type.

How do I convert Base64 to a PDF or image?

Select Decode text or file, paste the string and click Decode and download file. A `data:application/pdf;base64,` prefix can stay in place: its MIME type is used for the file. Without one, PDF, PNG, JPEG, GIF and ZIP are recognised from their first bytes and saved with the right extension.

Can Base64 be decrypted?

There is nothing to decrypt: Base64 is an encoding, not encryption. Anyone can decode it, so it must never be used to protect secrets.

Why is my Base64 invalid?

The decoder already handles URL-safe characters, missing padding, data: prefixes and line breaks. Remaining failures usually mean characters were lost or changed, for example + signs turned into spaces in a URL, or the string was cut short.

Does it support UTF-8 and emoji?

Yes. Text is converted to UTF-8 bytes before encoding and decoded as UTF-8, so accents, other alphabets and emoji are preserved.

Is my data uploaded?

No. Encoding and decoding, including files, happen entirely in your browser.