Base64 decode

Decode Base64 or Base64URL back to text, hex or a file, and see what is inside: JSON, gzip, an image or a PDF.

loading Base64 decode
About this tool

What does Base64 decode do?

Decoding Base64 turns a string such as SGVsbG8sIHdvcmxkIQ== back into the bytes it stands for. Those bytes are often plain text, but just as often they are JSON from an API, a gzip-compressed payload, a PNG pasted from a data URL or an entire PDF attachment taken from an email or a webhook. A decoder that only prints text shows garbage in most of those cases.

This page opens the Base64 encoder and decoder already in Decode mode and looks inside what it decodes: it detects gzip (up to three layers), images, PDF, JSON and text, and labels the chain it found, for example "Base64 → gzip → JSON". It accepts standard Base64, the URL-safe variant with - and _, strings without the = padding, line breaks in the middle and full data:...;base64, URLs. Everything is decoded in your browser; nothing you paste is uploaded. To go the other way, use Base64 encode.

How to decode Base64

  1. Paste the Base64 into the Base64 to decode box, or drop a text file that contains it. A data: prefix and line breaks are fine.
  2. Read the tag above the result: it shows each layer that was opened and the type and size of the content, such as application/json · 27 B.
  3. Text and JSON appear in Decoded content; JSON is pretty-printed. Images get a preview, a PDF gets a download notice.
  4. If accents come out wrong, change Character set (UTF-8, UTF-16 LE/BE or Latin-1). To see the raw bytes, set Show result as to Hex.
  5. Click Copy for text, or Download to save the bytes with the right extension (decoded.json, decoded.png, decoded.pdf).

Examples

Plain text

SGVsbG8sIHdvcmxkIQ==

Decodes to:

Hello, world!

A JWT segment (Base64URL without padding)

The middle part of a token uses -, _ and no =. It is decoded as is and shown as JSON:

eyJzdWIiOiIxMjMiLCJyb2xlIjoiYWRtaW4ifQ
{
  "sub": "123",
  "role": "admin"
}

To read and verify a whole token, use the JWT decoder.

Gzip-compressed JSON

H4sIAAAAAAAAE6tWys9WsiopKk3VUcosSc0tVrKKNtQx0jGOrQUAutiLtxsAAAA=

The tag reads "Base64 → gzip → JSON" and the result is:

{
  "ok": true,
  "items": [
    1,
    2,
    3
  ]
}

Common errors

  • Character 8 is not valid Base64: the input has a character outside the alphabet, here the @ in SGVsbG8@IHdvcmxk. Remove stray quotes, \n escapes copied from JSON or other characters at that position.
  • The length is not valid Base64: the text was cut, for example when a log truncated it. Copy it again from the source; a missing = alone is not a problem.
  • Accents look wrong (é, �): the bytes are text in another character set. Try Latin-1 or UTF-16.
  • Result marked as binary: the content is not text, an image or a PDF. Download it or switch to Hex to inspect the first bytes.

FAQ

Is Base64 a kind of encryption?

No. Anyone can decode it without a key, as this page shows. It only makes bytes safe to carry in text formats. Never treat a Base64 value as secret.

Can I decode an image or a PDF?

Yes. PNG, JPEG, GIF and WebP are previewed, PDF is recognized, and both can be downloaded as files.

Why does my Base64 end with = or ==?

Base64 writes 3 bytes as 4 characters. When the data length is not a multiple of 3, = fills the last group. Decoding works with or without it.

Is my data sent anywhere?

No. Decoding runs in the page with JavaScript; nothing leaves your device.

How to decode Base64 in code

JavaScript

In the browser, atob returns bytes as a string; turn them into UTF-8 text with TextDecoder. In Node.js, Buffer also reads Base64URL.

const bytes = Uint8Array.from(atob('T2zDoSwgbXVuZG8h'), c => c.charCodeAt(0));
new TextDecoder().decode(bytes); // 'Olá, mundo!'
Buffer.from('eyJzdWIiOiIxMjMiLCJyb2xlIjoiYWRtaW4ifQ', 'base64url').toString('utf8');

Python

import base64
base64.b64decode("T2zDoSwgbXVuZG8h").decode("utf-8")  # 'Olá, mundo!'
s = "eyJzdWIiOiIxMjMiLCJyb2xlIjoiYWRtaW4ifQ"
base64.urlsafe_b64decode(s + "=" * (-len(s) % 4)).decode("utf-8")

Go

out, err := base64.StdEncoding.DecodeString("T2zDoSwgbXVuZG8h")
// Base64URL without padding:
out, err = base64.RawURLEncoding.DecodeString("eyJzdWIiOiIxMjMiLCJyb2xlIjoiYWRtaW4ifQ")

Bash

printf '%s' 'T2zDoSwgbXVuZG8h' | base64 --decode
Report a problem