niftytools.dev
advertisement

Base64 Encoder / Decoder

Encode text to Base64 or decode Base64 back to plain text. Upload files too.

0 characters
0 characters
advertisement
advertisement

What is Base64 Encoding?

Base64 is a binary-to-text encoding scheme that converts binary data into a string of 64 printable ASCII characters (A–Z, a–z, 0–9, + and /). It was designed to safely transmit binary data over channels that only handle plain text. The name comes from the 64 characters used in the encoding alphabet. Base64 is not encryption — it is purely an encoding format and can be decoded by anyone without a key.

Common Use Cases for Base64

  • Data URIs — Embed images directly in HTML or CSS without a separate file request by encoding them as a Base64 data URI (e.g., <img src="data:image/png;base64,…">).
  • API payloads — Many REST APIs transmit binary files (images, PDFs) inside JSON by encoding them as Base64 strings.
  • JWT tokens — JSON Web Tokens use Base64url encoding (a URL-safe variant) for their header and payload sections.
  • Email attachments — The MIME standard uses Base64 to encode attachments so they can travel through email servers safely.
  • Basic authentication — HTTP Basic Auth credentials are sent as a Base64-encoded "username:password" string.

Base64 Encoding vs. Encryption

Base64 is frequently confused with encryption, but they serve completely different purposes. Encryption scrambles data with a secret key so only authorised parties can read it. Base64 simply re-encodes data so it is safe to include in text-only contexts. Anyone can decode a Base64 string instantly — never use it to protect sensitive information such as passwords, API secrets, or private data.

How to Encode Text to Base64

  1. Type or paste your text into the input box, or click Upload File to encode a file.
  2. The Base64 output appears instantly in the result box as you type.
  3. Click copy to grab the encoded string, or use the swap button to switch to decode mode.

To decode instead, paste a Base64 string and switch the tool to decode mode — it converts the encoded string back to its original text or file. Encoding and decoding are exact inverses, so a value encoded here will decode identically anywhere else.

What is Base64url (URL-Safe Base64)?

Standard Base64 uses + and /, which have special meaning inside URLs and filenames. Base64url is a variant that replaces + with -and / with _, and usually drops the trailing =padding, so the result can be dropped straight into a URL, query parameter, or JWT without extra escaping. The decoded data is identical — only the alphabet differs.

Frequently Asked Questions

Is Base64 the same as encryption?

No. Base64 is an encoding scheme, not encryption. Any Base64 string can be decoded immediately by anyone. Use proper encryption (AES, RSA) if you need to protect data. Base64 is purely for safe transmission of binary data in text-based systems.

Why does Base64 output end with = or ==?

Base64 encodes data in 3-byte chunks. If the input length is not a multiple of 3, padding characters (=) are added to make the output a multiple of 4 characters. One = means one byte of padding was needed; == means two bytes. Some implementations omit padding (Base64url), which is fine as long as the decoder expects it.

Can I encode files to Base64?

Yes. Click the "Upload File" button to select any file from your device. The tool reads the file locally in your browser, encodes it to Base64, and displays the result. The file is never uploaded to any server. This is useful for embedding small images or other binary assets directly into code.

Does encoding increase file size?

Yes. Base64 encoding increases the data size by approximately 33%. Every 3 bytes of binary data become 4 ASCII characters. This is a known trade-off — you gain compatibility with text-based systems at the cost of additional bytes.

How do I decode a Base64 string?

Paste the Base64 string into the input and switch the tool to decode mode. It converts the encoded string back to the original text or file. If decoding fails, the string is usually truncated, contains invalid characters, or is missing its padding.

What is a Base64 data URI?

A data URI embeds a file directly inside HTML or CSS as text, avoiding a separate network request. It looks like data:image/png;base64,iVBORw0KGgo… — the MIME type, the word base64, and then the encoded bytes. Encode any small image or file here and prepend the data: prefix to build one.

Is Base64 URL-safe?

Standard Base64 is not, because it uses + and /. Use the Base64url variant (with - and _) when the value goes into a URL, query string, cookie, or JWT so it does not need extra percent-encoding.