UtilityKit

500+ fast, free tools. Most run in your browser only; Image & PDF tools upload files to the backend when you run them.

Base64

Encode and decode Base64 strings

About Base64

Base64 Encoder/Decoder is a fast, browser-only tool for converting text to and from Base64 encoding. Type or paste any string — a JSON payload, an SSH public key, a data URI fragment, or an API credential — and the tool outputs the encoded representation instantly. Switch to decode mode to convert any Base64 or URL-safe Base64 string back to its original text. The URL-safe variant replaces + and / with - and _ so the encoded value can be placed in a URL query parameter or HTTP header without percent-encoding. All operations run in your browser using the native btoa/atob APIs backed by TextEncoder for full UTF-8 support — nothing leaves your machine. Developers reach for this when hand-crafting HTTP Basic Auth headers, inspecting email MIME parts, embedding small images as data URIs, or decoding opaque identifiers returned by third-party services.

Why use Base64

Full UTF-8 and Unicode Support

Standard btoa fails silently on non-ASCII characters. This tool uses TextEncoder to convert the string to UTF-8 bytes before encoding, so emoji, accented characters, CJK glyphs, and Arabic text all encode and decode correctly every time.

URL-Safe Variant in One Toggle

Standard Base64 uses + and / which are special characters in URLs. One toggle switches to the RFC 4648 URL-safe alphabet (- and _) with optional padding removal, so encoded values drop straight into query strings and JWT components without escaping.

Instant Real-Time Output

Output updates on every keystroke with zero latency because the entire operation runs synchronously in the browser. There are no network round-trips, no loading spinners, and no delay even for kilobyte-length inputs.

Zero Server Transmission

Credentials, private keys, tokens, and personal data never leave the browser tab. This makes the tool safe to use with secrets that must not touch external servers, unlike online tools that proxy through a backend or log requests.

Graceful Invalid-Input Handling

When decoding, the tool detects illegal characters and incorrect padding and reports a clear error message rather than returning garbled output or throwing an uncaught exception. This helps quickly identify truncated or corrupted encoded strings.

Works with Data URIs and MIME Parts

Base64 is the encoding used in CSS background-image data URIs, HTML inline images, and email MIME attachments. The tool strips the data: header prefix automatically when decoding so you can paste a full data URI without pre-processing it.

How to use Base64

  1. Select 'Encode' or 'Decode' mode using the toggle at the top of the tool.
  2. Paste or type your input text into the input area — for decode mode, paste the Base64 string.
  3. The output appears instantly in the result area as you type; no button press is needed.
  4. To switch to URL-safe Base64, enable the 'URL-safe' toggle — this replaces + with - and / with _ and strips padding = characters.
  5. Click the copy button next to the output to copy the encoded or decoded result to your clipboard.
  6. To start over, click 'Clear' to reset both input and output fields simultaneously.

When to use Base64

  • Constructing an HTTP Basic Authentication header by encoding username:password to Base64.
  • Decoding a JWT header or payload segment (the first two dot-separated parts are Base64URL-encoded).
  • Embedding a small PNG or SVG as a data URI in a CSS file or HTML attribute.
  • Inspecting a MIME email attachment encoded as Base64 in a raw .eml file.
  • Encoding an API key or secret before storing it in an environment variable that must be ASCII-safe.
  • Verifying that a Base64 string returned by a third-party service decodes to the expected plaintext or JSON.

Examples

Encode an HTTP Basic Auth credential

Input: alice:s3cr3tP@ssword

Output: YWxpY2U6czNjcjN0UEBzc3dvcmQ=

Decode a Base64 API response fragment

Input: eyJzdGF0dXMiOiJvayIsInVzZXIiOiJhbGljZSJ9

Output: {"status":"ok","user":"alice"}

Encode a Unicode string with emoji

Input: Hello 🌍

Output: SGVsbG8g8J+MjQ==

Tips

  • To decode a JWT payload without a dedicated JWT tool, take the second dot-separated segment and paste it here in URL-safe decode mode — remember to re-add = padding if needed (pad to a length divisible by 4).
  • When building a Basic Auth header, encode the string as username:password (colon-separated, no spaces), then prepend 'Basic ' to the result.
  • A Base64-encoded string is always approximately 33% longer than the original input — factor this into cookie or header size budgets.
  • PEM certificate files (-----BEGIN CERTIFICATE-----) contain standard Base64 with newlines every 76 characters. Paste the block between the header and footer lines for clean decoding.
  • URL-safe Base64 without padding is the format used in JWTs, Google's signed URLs, and Firebase storage tokens — enable both 'URL-safe' and 'No padding' when working with those systems.

Frequently Asked Questions

Is Base64 a form of encryption?
No. Base64 is purely an encoding scheme — it represents binary data using 64 printable ASCII characters. It provides no confidentiality; anyone who sees the encoded string can decode it in seconds. Never rely on Base64 alone to protect sensitive data.
What is the difference between standard Base64 and URL-safe Base64?
Standard Base64 uses + and / in its alphabet, which are reserved characters in URLs. URL-safe Base64 (RFC 4648 §5) replaces + with - and / with _ so the encoded string can appear in a URL path or query parameter without percent-encoding. The = padding character is also often omitted.
Why does Base64 output end with one or two equals signs?
Base64 encodes every 3 bytes of input as 4 characters. When the input length is not a multiple of 3, one or two = padding characters are appended to make the total output length a multiple of 4. They carry no data — just alignment.
Will this tool handle binary files like images or PDFs?
Text input only in the browser version. To Base64-encode a binary file, use the file-upload variant of the tool (if available) or a command-line utility such as base64 -i file.png. The output string can then be pasted here for inspection or decoding.
Why does my encoded output differ between this tool and another Base64 encoder?
The most common cause is character encoding. If the other tool encodes the string as Latin-1 (ISO-8859-1) instead of UTF-8, you will get a different result for any non-ASCII character. This tool always uses UTF-8, which is the modern standard.
Can I decode a Base64 string that has whitespace or line breaks in it?
Yes. The tool strips whitespace before decoding, which handles the common case of Base64 encoded with line wrapping at 76 characters (as used in PEM certificates and MIME email bodies).
What happens if I try to decode an invalid Base64 string?
The tool shows a clear error message identifying the problem — typically an unexpected character or incorrect padding. It will not return corrupted output or crash silently.
Does this tool support Base32 or Base58 encoding?
This tool covers Base64 and URL-safe Base64. Base32 is used in TOTP secrets and DNS records; Base58 is used in cryptocurrency addresses — both have different alphabets and padding rules and are separate tools.

Explore the category

Glossary

Base64
An encoding scheme that represents binary data using 64 printable ASCII characters (A-Z, a-z, 0-9, +, /). Defined in RFC 4648.
URL-safe Base64
A Base64 variant defined in RFC 4648 §5 that substitutes - for + and _ for / so the encoded string is safe to use in URLs and filenames without percent-encoding.
Padding
The = characters appended to Base64 output to ensure the total length is a multiple of 4. Required by strict parsers but often omitted in URL contexts.
TextEncoder
A browser Web API that converts a JavaScript string to a Uint8Array of UTF-8 bytes, enabling correct Base64 encoding of non-ASCII characters.
Data URI
A URI scheme (data:mediatype;base64,<encoded>) that embeds file content directly in HTML or CSS, using Base64 to represent binary data as ASCII text.
MIME
Multipurpose Internet Mail Extensions — the standard that defines how email attachments and multipart bodies are encoded, commonly using Base64 for binary parts.