DEV Community

楊東霖
楊東霖

Posted on • Originally published at devplaybook.cc

Base64 Decode Online: Instantly Decode Any Base64 String for Free

Base64 Decode Online: Instantly Decode Any Base64 String for Free

You've got a Base64 string — a JWT payload, an image in an API response, a config value in an environment file. You need the original content now, not after installing a tool or writing a decode script.

Decode Base64 Online →


What Is Base64?

Base64 is an encoding scheme that converts binary data into ASCII text using 64 printable characters (A–Z, a–z, 0–9, +, /) plus = for padding.

It's not encryption — it provides zero security. Anyone can decode it instantly. The purpose is safe transport: binary data often breaks systems that only handle text (email, HTTP headers, JSON, HTML attributes).

What Base64 looks like

Original: Hello, World!

Base64: SGVsbG8sIFdvcmxkIQ==


When You'll Need to Decode Base64

JWT Tokens (Most Common)

JWTs have three Base64-encoded parts separated by dots:

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
Enter fullscreen mode Exit fullscreen mode

Decode the middle section (payload):

{
  "sub": "1234567890",
  "name": "John Doe",
  "iat": 1516239022
}
Enter fullscreen mode Exit fullscreen mode

API Responses with Image Data

{
  "image": "iVBORw0KGgoAAAANSUhEUgAA..."
}
Enter fullscreen mode Exit fullscreen mode

That's a PNG or JPEG encoded as Base64. Decode it to get the actual file.

HTTP Basic Auth Headers

Authorization: Basic dXNlcjpwYXNzd29yZA==
Enter fullscreen mode Exit fullscreen mode

Decode dXNlcjpwYXNzd29yZA==user:password

Environment Variables

Some tools store configuration as Base64 to avoid escaping issues:

DATABASE_URL=cG9zdGdyZXNxbDovL3VzZXI6cGFzc0Bob3N0OjU0MzIvZGI=
Enter fullscreen mode Exit fullscreen mode

SSH Keys and Certificates

PEM files contain Base64-encoded key material between the -----BEGIN----- and -----END----- lines.


Standard Base64 vs URL-Safe Base64

There are two variants:

Variant Characters used Padding
Standard + and / =
URL-safe - and _ Sometimes omitted

URL-safe Base64 replaces +- and /_ so the encoded string can appear in URLs without percent-encoding.

JWTs use URL-safe Base64 without padding.

If decoding fails, try switching variants.


How to Decode Base64 in Code

JavaScript (Browser + Node.js)

// Decode
const encoded = "SGVsbG8sIFdvcmxkIQ==";
const decoded = atob(encoded);
console.log(decoded); // "Hello, World!"

// Node.js (Buffer)
const buf = Buffer.from("SGVsbG8sIFdvcmxkIQ==", "base64");
console.log(buf.toString("utf-8")); // "Hello, World!"

// URL-safe Base64 decode (Node.js)
function decodeBase64Url(str) {
  str = str.replace(/-/g, "+").replace(/_/g, "/");
  while (str.length % 4) str += "=";
  return Buffer.from(str, "base64").toString("utf-8");
}

// Decode JWT payload
function decodeJwtPayload(token) {
  const payload = token.split(".")[1];
  return JSON.parse(decodeBase64Url(payload));
}
Enter fullscreen mode Exit fullscreen mode

Python

import base64

# Standard decode
encoded = b"SGVsbG8sIFdvcmxkIQ=="
decoded = base64.b64decode(encoded).decode("utf-8")
print(decoded)  # "Hello, World!"

# URL-safe decode
url_safe = "SGVsbG8sIFdvcmxkIQ"
decoded = base64.urlsafe_b64decode(url_safe + "==").decode("utf-8")

# Decode binary file
import base64
with open("output.png", "wb") as f:
    f.write(base64.b64decode(image_base64_string))
Enter fullscreen mode Exit fullscreen mode

Bash / Command Line

# Decode
echo "SGVsbG8sIFdvcmxkIQ==" | base64 -d
# Hello, World!

# Decode a file's Base64 content
base64 -d encoded.txt > output.bin

# Decode and pipe to jq (for Base64-encoded JSON)
echo "eyJrZXkiOiJ2YWx1ZSJ9" | base64 -d | jq .
Enter fullscreen mode Exit fullscreen mode

Go

import (
    "encoding/base64"
    "fmt"
)

encoded := "SGVsbG8sIFdvcmxkIQ=="
decoded, err := base64.StdEncoding.DecodeString(encoded)
if err != nil {
    panic(err)
}
fmt.Println(string(decoded)) // "Hello, World!"

// URL-safe
decodedUrl, err := base64.URLEncoding.DecodeString(encoded)
Enter fullscreen mode Exit fullscreen mode

Troubleshooting Decode Errors

"Invalid character" or "Incorrect padding"

Base64 strings must have a length that's a multiple of 4. If padding is missing, add = signs:

// Fix padding
const fixPadding = (str) => str + "=".repeat((4 - str.length % 4) % 4);
Enter fullscreen mode Exit fullscreen mode

Getting garbage output

If decoded output looks garbled, the encoding might be:

  • URL-safe Base64 (try replacing -+ and _/)
  • Multi-layer encoded (decode twice)
  • A different charset (try Latin-1 instead of UTF-8)

Input contains whitespace

Encoded strings sometimes have newlines inserted for readability. Strip whitespace before decoding:

const cleaned = encoded.replace(/\s/g, "");
Enter fullscreen mode Exit fullscreen mode

Is Decoding Base64 Safe?

Decoding doesn't pose a security risk by itself. However:

  • Don't decode tokens in public tools if they contain sensitive credentials
  • Base64 ≠ encryption — never use it to "hide" passwords
  • Validate decoded output — ensure it's the format you expect before using it

For sensitive production data, decode client-side (in browser or local terminal) rather than sending data to a third-party service.


Related Tools


Conclusion

Base64 decoding is a daily task for developers — JWT debugging, API payload inspection, credential management. A reliable Base64 decoder online saves you from writing throwaway scripts.

Decode Base64 Online for Free →


Level Up Your Dev Workflow

Found this useful? Explore DevPlaybook — cheat sheets, tool comparisons, and hands-on guides for modern developers.

🛒 Get the DevToolkit Starter Kit on Gumroad — 40+ browser-based dev tools, source code + deployment guide included.

Top comments (0)