Base64 String Encoder/Decoder

Encode ↔ decode Base64 strings locally

Supports URL-safe Base64 and instant copy — all in your browser

Last updated: January 25, 2026
Frank Zhao - Creator
CreatorFrank Zhao

Base64 to string

Decode URL safe

String to base64

Encode URL safe

Introduction / overview

This Base64 String Encoder/Decoder converts plain text to Base64 and decodes Base64 back into text. It also supports URL-safe Base64 (often called Base64URL), which is commonly used in tokens and web APIs.

Important: Base64 is an encoding, not encryption. If you need confidentiality, use real encryption (and treat Base64 as just a transport format).

Who is this for?

  • Developers debugging API payloads, tokens, and data URLs.
  • Anyone copy/pasting Base64 from logs and needing quick decoding.
  • People preparing safe-to-transmit strings for emails, JSON, or config files.

Nice pairing: If you’re packaging data for a workflow, you might also like our Hash Text (to verify integrity) or Encrypt / Decrypt Text (to protect sensitive content).

How to use / quick start

1

Decode Base64 to text

Paste your Base64 into “Base64 to string”. Enable “URL-safe” if the value uses - and _ instead of ++ and //.

2

Encode text to Base64

Type any text into “String to base64”. Toggle “URL-safe” if you need a Base64URL output for web usage.

3

Copy the result

Use the copy button to avoid hidden whitespace issues. If the decoder shows “Invalid base64 string”, re-check URL-safe mode and padding.

How to read the output

  • Decoded text may contain whitespace, quotes, or JSON. Treat it as data: copy it and inspect it carefully.
  • If you expect binary content (like an image), Base64-to-text is not the right view; you usually want to keep it as Base64 or use a file tool.

Step-by-step examples

Example 1: Why “Man” becomes “TWFu”

The ASCII bytes for “Man” are 77, 97, 11077,\ 97,\ 110. Base64 packs 3 bytes into 24 bits, then splits into 4 groups of 6 bits.

2424==3×83\times 8==4×64\times 6

In terms of Base64 output characters, you get 4 characters for every 3 input bytes. That’s why encoded strings often look “longer” than the original.

Input=“Man”Base64=“TWFu”\text{Input} = \text{“Man”} \quad \Rightarrow \quad \text{Base64} = \text{“TWFu”}

Try it: put TWFu in “Base64 to string” to get Man.

Example 2: Base64URL padding and why “=” disappears

Standard Base64 output length is typically a multiple of 44. When a system uses Base64URL, it may remove padding characters ==.

pp==(4(Lmod4))mod4\bigl(4 - (L\bmod 4)\bigr)\bmod 4

Here LL is the length of the Base64URL string (without padding), and pp is how many padding characters you would add back (0, 1, or 2) to make it standard Base64.

Quick sanity check

  • If your string contains - or _, enable URL-safe.
  • If it fails to decode, missing padding is a common cause.

Real-world examples / use cases

1) Debug a data URL header

Background: You copied an image string that starts with data:image/png;base64,.

Input: Paste the full value into “Base64 to string”.

Result: The tool ignores the prefix and decodes the Base64 portion. If the output is unreadable, that’s expected for binary.

How to apply: Keep it encoded, or extract the MIME type and confirm it matches expectations.

2) Inspect a token-like string

Background: You have a compact string from an API response.

Input: Try decoding with URL-safe enabled.

Result: If it decodes into JSON-like text, you can quickly see fields. If it stays unreadable, it may be encrypted or compressed.

How to apply: If it’s JSON, you can validate integrity with our Hash Text tool.

3) Send binary-ish content through text channels

Background: A system only accepts plain text, but you need to transport bytes.

Input: Encode the original text to Base64.

Result: A Base64 string that is safe to paste into many tools (logs, JSON fields, emails).

How to apply: On the receiving side, decode back to the original.

4) Store “safe” strings in configs

Background: A config format breaks on special characters or newlines.

Input: Encode your text (possibly including newlines) into Base64.

Result: A single-line payload. For URL contexts, use URL-safe Base64.

How to apply: Decode only where needed; consider encrypting first for secrets.

Common scenarios / when to use

API debugging

Decode fields returned as Base64 to see what’s inside.

Integrity checks

Encode data consistently before hashing with Hash Text.

Email and copy/paste

Convert text into a single-line string that survives pasting.

Config portability

Store text safely in formats sensitive to whitespace.

Reproducible bugs

Share a Base64 payload that reproduces an issue exactly.

URL-safe outputs

When a system rejects + or /.

When it might not be the right tool

  • If you need to protect secrets, use encryption first (Base64 alone does not hide anything). Consider Encrypt / Decrypt Text.
  • If you expect a file preview (image/audio), you likely want a dedicated file viewer rather than “decode to text”.

Tips & best practices

Pro tip: If decoding fails, toggle URL-safe, then check for missing padding. Base64URL often omits ==.

  • Avoid adding extra line breaks. Some Base64 strings (PEM-like formats) insert newlines every 6464 or 7676 characters.
  • If you copied from a web page, watch out for invisible characters (non-breaking spaces). Re-copy using the copy button.
  • Need a stable checksum? Hash the encoded or decoded text using Hash Text.
  • If the decoded output looks like random symbols, that can still be valid: you may be decoding compressed or encrypted bytes.

Calculation method / formula explanation

Base64 maps raw bytes into characters from a fixed alphabet. Conceptually:

3 bytes (24 bits)  4 groups (6 bits each)  4 characters3\ \text{bytes}\ (24\ \text{bits})\ \Rightarrow\ 4\ \text{groups}\ (6\ \text{bits each})\ \Rightarrow\ 4\ \text{characters}

Each 6-bit value is an index into the Base64 alphabet.

Padding rules

If the input length is not a multiple of 33 bytes, standard Base64 adds padding == to make the output length a multiple of 44.

  • If you have 11 leftover byte, you get 22 Base64 chars and ====.
  • If you have 22 leftover bytes, you get 33 Base64 chars and ==.

Base64 vs Base64URL

Base64URL uses the same 6-bit grouping, but replaces characters to be URL-friendly:

+  +\ \to\ -\quad/\ \to\ _\quad== (padding may be removed)\ \text{(padding may be removed)}

Related concepts / background

Common prefixes and formats

  • data:<mime>;base64, is a “data URL” prefix. The Base64 data comes after the comma.
  • Some systems insert line breaks for readability. If you see many newlines, remove them before decoding.

Encoding vs hashing vs encryption

Encoding

Reversible transform for transport. Base64 is here.

Hashing

One-way fingerprint for integrity. Try Hash Text.

Encryption

Protects confidentiality. Try Encrypt / Decrypt Text.

Frequently asked questions (FAQs)

Is Base64 encryption?

No. Base64 is a reversible encoding. Anyone can decode it. If you need confidentiality, encrypt first, then Base64-encode if you need a text transport.

Why does my Base64 string fail to decode?

The common causes are: wrong URL-safe setting, missing padding ==, or hidden whitespace/newlines.

What’s the difference between Base64 and Base64URL?

Base64URL replaces characters that can be awkward in URLs and may remove padding. The underlying bit grouping is the same.

Why is the encoded text longer?

Base64 turns 33 bytes into 44 characters. The overhead is about 431.33\frac{4}{3} \approx 1.33.

Can I Base64-encode any text?

Yes. This tool is designed for text input. For arbitrary binary files, you typically need a file-to-Base64 workflow.

I decoded something and it looks like garbage. Is that normal?

It can be. The decoded bytes might represent compressed data, encrypted data, or non-text binary. In that case “text view” will look random.

Does this run locally?

Yes — the conversion runs in your browser, and the copy button uses your clipboard.

Limitations / disclaimers

  • Base64 does not provide security. Never treat Base64 as a protection mechanism for passwords, API keys, or personal data.
  • Decoding assumes the underlying bytes represent text. If your payload is binary, the “decoded text” may not be meaningful.
  • Always validate inputs in production systems. This tool is for learning, debugging, and day-to-day conversions.

External references / sources

Base64 String Encoder/Decoder - Encode & Decode (URL-safe)