# Base64 Decoder

> Paste a Base64 or Base64URL string to get the original text, plus the raw bytes in hex.

- Page: https://decoder.tools/base64-decoder
- Category: Data, Radix & String
- Status: live, runs in the browser
- Last reviewed: 2026-10-23

A Base64 decoder turns a Base64 string back into the bytes it encodes. Every 4 Base64 characters become 3 bytes, which are then shown as text when they form valid UTF-8.

## Example

```text Input
SGVsbG8sIHdvcmxkIQ==
```

```text Output
Hello, world!
```

The decoder also reports 13 decoded bytes and their hex values (`48 65 6c 6c 6f …`), which helps when the payload isn't plain text.

## What is Base64?

Base64 is a way to write arbitrary bytes using only 64 safe ASCII characters: `A–Z`, `a–z`, `0–9`, `+` and `/`. It exists because many systems only carry text reliably. Email bodies, JSON strings, HTTP headers, XML and URLs all break on raw binary, so binary data gets Base64-encoded before it goes in.

The encoding works on groups of 3 bytes (24 bits). Each group is split into four 6-bit numbers, and each number picks one character from the alphabet. When the input length isn't a multiple of 3, the output is padded with one or two `=` signs. That is why Base64 output is always about 33% larger than the input.

**Base64URL** (RFC 4648 §5) is the variant used in JWTs, URLs and file names. It replaces `+` with `-` and `/` with `_`, and usually drops the `=` padding. This decoder accepts both forms, so you don't need to convert first.

Base64 is not encryption. There is no key, and anyone can reverse it in one step.

## How to recognize Base64

- Only `A–Z`, `a–z`, `0–9`, `+`, `/` (or `-`, `_` for Base64URL).
- Length is usually a multiple of 4, often ending in `=` or `==`.
- Strings starting with `eyJ` are Base64 for `{"`, which almost always means JSON, and very often a JWT.
- `H4sI` at the start means gzip-compressed data. Decode it with the [Gzip decompressor](/gzip-decompressor) instead.
- `iVBORw0KGgo` is the start of a PNG image, and `JVBERi0` is the start of a PDF.

## How to use the Base64 decoder

1. Paste the Base64 string into the input box. Line breaks, spaces and missing padding are fine.
2. Read the decoded text in the output panel.
3. Check the byte count and hex preview. If the text looks garbled, the data is binary (an image, compressed data or ciphertext) rather than text.

## Decode Base64 in code

```js JavaScript (browser and Node.js)
// atob() returns a "binary string"; TextDecoder turns the bytes into UTF-8 text
const bytes = Uint8Array.from(atob("SGVsbG8sIHdvcmxkIQ=="), (c) => c.charCodeAt(0));
console.log(new TextDecoder().decode(bytes)); // Hello, world!

// Node.js also has Buffer, which accepts Base64URL too
console.log(Buffer.from("SGVsbG8sIHdvcmxkIQ", "base64url").toString("utf8"));
```

```python Python
import base64

print(base64.b64decode("SGVsbG8sIHdvcmxkIQ==").decode("utf-8"))  # Hello, world!

# Base64URL without padding: add the padding back first
s = "SGVsbG8sIHdvcmxkIQ"
print(base64.urlsafe_b64decode(s + "=" * (-len(s) % 4)).decode("utf-8"))
```

```sh Command line (Linux and macOS)
echo 'SGVsbG8sIHdvcmxkIQ==' | base64 -d
```

## Base64 at a glance

| | |
|---|---|
| Specification | RFC 4648 (Base64 and Base64URL) |
| Alphabet | `A–Z a–z 0–9 + /`, padding `=` |
| URL-safe alphabet | `A–Z a–z 0–9 - _`, padding usually omitted |
| Size overhead | About 33% (4 characters for every 3 bytes) |
| Reversible without a key | Yes. It is an encoding, not encryption |

## FAQ

### Is Base64 encryption?

No. Base64 only changes how bytes are written down. Anyone can decode it, so a password or API key stored as Base64 is effectively stored in plain text.

### Why does my Base64 string end with = or ==?

That is padding. Base64 encodes 3 bytes at a time. If the last group has only 1 or 2 bytes, the encoder adds `==` or `=` so the output length stays a multiple of 4. Many encoders, including JWT libraries, leave the padding off. This decoder adds it back automatically.

### What is the difference between Base64 and Base64URL?

Base64URL swaps the two characters that have special meaning in URLs: `+` becomes `-` and `/` becomes `_`. It also usually omits padding. Paste either kind here and it decodes the same way.

### Why is my decoded output gibberish?

The bytes aren't text. Look at the hex preview: `1f 8b` is gzip, `89 50 4e 47` is a PNG image, `25 50 44 46` is a PDF. Random-looking bytes with no pattern are usually encrypted or hashed data, which Base64 decoding can't reverse.

### Can I decode a Base64 image?

You can decode it to bytes here and check the file signature in the hex preview. For a full `data:image/png;base64,…` string, the [Data URI parser](/data-uri-parser) also shows the MIME type and payload size.
