Developer Tools

How to Decode Base64 into Text, an Image or a File

A long string of random-looking letters in a log, an email or an API response is often Base64. Here is how to see what is really inside.

In this article
  1. Spotting Base64
  2. How to decode
  3. Common errors and fixes
  4. Decoding images embedded in HTML or CSS
  5. Decoding JWTs
  6. Is it safe to decode unknown data?
  7. Reading email source
  8. Privacy

Spotting Base64

Base64 strings contain only letters, digits, “+”, “/” (or “-” and “_” in the URL-safe variant) and often end with one or two “=” signs. Their length is usually a multiple of four. Some beginnings give away the content type:

Starts withUsually means
iVBORw0KGgoPNG image
/9j/JPG image
R0lGODGIF image
JVBERi0PDF document
UEsDBZIP (also .docx, .xlsx)
eyJJSON text, e.g. part of a JWT
Base64 DecoderDecode Base64 and data URIs back to readable text or a downloadable file. Detects images, PDFs and ZIPs, accepts URL-safe input and explains errors.
Open the free tool

How to decode

  1. Paste the string into the Base64 Decoder. A data: prefix and line breaks are removed automatically.
  2. If the result is text, it appears straight away.
  3. If it is a PNG, JPG, GIF, WebP, PDF or ZIP, the tool recognises it, shows a preview for images, and offers a download with the right file extension.

Both standard and URL-safe Base64 are accepted, with or without padding.

Common errors and fixes

  • Invalid character: the string may include quotes, a trailing comma or a backslash from JSON. Copy only the value between the quotes.
  • Truncated input: logs often cut long strings. If the image is half grey or the PDF will not open, the data is incomplete.
  • Garbled text: the data may not be text at all – check whether it is a file.
  • Escaped slashes: JSON sometimes writes “/” as “\/”. Replace “\/” with “/” first.

Decoding images embedded in HTML or CSS

Web pages sometimes embed icons and logos as data:image/png;base64,… strings. Copy everything after the comma (or the whole data URI – the prefix is stripped automatically), decode it, and download the image as a normal file. This is a quick way to recover a small icon whose original file you no longer have.

Decoding JWTs

A JSON Web Token has three Base64 parts separated by dots. You can decode the first two here, but the JWT Decoder does it in one step, shows expiry dates and can verify HMAC signatures.

Is it safe to decode unknown data?

Decoding itself is harmless – it only turns text back into bytes. Be careful with what you do next: do not open downloaded files from untrusted sources, especially executables or documents with macros. The decoder recognises common file types so you know what you are dealing with before you open anything.

Reading email source

If you view the raw source of an email, attachments and some message bodies appear as Base64 blocks under headers like Content-Transfer-Encoding: base64. Copy the block (without the headers) and decode it to recover the attachment or text – handy when an email client shows a message incorrectly.

Privacy

Base64 strings in logs can hold personal data, documents or credentials. ConvertNest decodes them in your browser; nothing is uploaded. To encode data, use the Base64 Encoder.

Base64 DecoderDecode Base64 and data URIs back to readable text or a downloadable file. Detects images, PDFs and ZIPs, accepts URL-safe input and explains errors.
Open the free tool
Keep reading

Related articles

All articles
Dev

What Is Base64 – and When Should You Use It?

Base64 shows up in emails, web pages, API keys and data URIs. It is simple once you see what problem it solves – and what it does not do.

3 min read
Dev

How to Read Messy Links Full of % Codes

Links copied from emails, search results and ads are often a jumble of percent codes. Decoding them shows what they really say – and where they really go.

3 min read
Dev

How to Read JSON – A Beginner’s Guide to API Responses

Almost every app and website exchanges data as JSON. Once you can read its structure, error messages and API responses stop looking like noise.

3 min read