Base64 Encoder & Decoder
Encode and decode Base64 strings online. Supports UTF-8 text and URL-safe Base64. All processing runs locally in your browser.
Last updated:
CommentsType or paste any text or file above to encode it to Base64, or paste Base64 to decode it back. Runs entirely in your browser — no upload.
What is Base64?
Base64 is a binary-to-text encoding scheme that represents raw bytes using 64 printable ASCII characters (A–Z, a–z, 0–9, +, /). It's the standard way to embed binary data — images, keys, certificates, payloads — inside text-only contexts like JSON, XML, HTTP headers, and email (MIME).
How to Base64 encode or decode
- 1Choose Encode or Decode at the top of the tool.
- 2Paste your text (for encode) or Base64 string (for decode) into the input area.
- 3The result appears instantly on the right — no button click required.
- 4Toggle URL-safe mode if the output will be placed in a URL or filename (replaces +/ with -_).
- 5Click Copy to grab the result.
Use Cases
Embed small images in CSS or HTML
Inline a favicon or icon as a data URL (`url(data:image/png;base64,...)`) to save a network round-trip.
Send binary data in JSON APIs
JSON has no native binary type. File uploads via REST are commonly Base64-encoded strings inside a JSON field.
HTTP Basic Auth
The `Authorization: Basic ...` header is literally `base64(username:password)`. Decode any Basic header here to inspect it.
Store SSH keys and certificates
PEM-formatted keys and certs are Base64-encoded DER, wrapped in `-----BEGIN X-----` markers.
Code Examples
Base64 in the browser
// Encode
const encoded = btoa("hello");
// Decode
const decoded = atob(encoded);Base64 UTF-8 safe
// btoa/atob only handle Latin1. For UTF-8:
const encoded = btoa(unescape(encodeURIComponent("你好")));
const decoded = decodeURIComponent(escape(atob(encoded)));Base64 in Python
import base64
b = base64.b64encode(b"hello").decode()
plain = base64.b64decode(b).decode()Base64 in Go
import "encoding/base64"
encoded := base64.StdEncoding.EncodeToString([]byte("hello"))
decoded, _ := base64.StdEncoding.DecodeString(encoded)Base64 from the shell
# macOS/Linux
echo -n "hello" | base64 # encode
echo "aGVsbG8=" | base64 -d # decodeKey Concepts
- URL-safe Base64
- A variant that replaces `+` with `-` and `/` with `_` so the result is safe in URLs, file names, and JWT tokens without further percent-encoding.
- Base64URL
- Same as URL-safe Base64, additionally omitting the `=` padding. Used inside JWTs (header, payload, and signature).
- MIME Base64
- The email variant: same alphabet as standard Base64, but wraps output at 76 characters per line.
- Padding (=)
- Base64 output length must be a multiple of 4. Missing bytes at the end are padded with `=`. Some parsers accept unpadded input — some don't.
Tips & Best Practices
- ▸Base64 encoding grows the payload by ~33%. For images larger than ~10 KB, HTTP-link them instead of inlining.
- ▸Base64 is encoding, not encryption. Anything you Base64 can be trivially decoded — never use it to 'hide' secrets.
- ▸When decoding fails, check for line breaks (`\n`) or spaces in the input — some parsers reject them, some accept them.
- ▸For URL-safe or JWT contexts, remember to also strip `=` padding — Base64URL is not the same as standard Base64.
Frequently Asked Questions
What is Base64?
Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string using 64 printable characters. It is commonly used to embed images in HTML/CSS or to transmit binary data over text-based protocols.
What is URL-safe Base64?
URL-safe Base64 replaces the + and / characters with - and _ so that the encoded string can be safely used in URLs and file names without additional escaping.
Can I convert a file or image to Base64 here?
Yes. Drop or paste a file and it is encoded to a Base64 string entirely in your browser — nothing is uploaded. This is the same output you would embed in a data: URL for inline images in HTML or CSS.
Is Base64 encryption?
No. Base64 is fully reversible without any key, so it provides zero confidentiality. Never use it to hide secrets — it is only an encoding for transporting binary data safely as text.
Try Next
HTML Encode/Decode
Encode and decode HTML entities (&, <, >, ", numeric references). Useful for sanitizing user content or debugging escaped markup.
Related Tools
URL Encode/Decode
Percent-encode and decode URLs online. Handles query strings, path segments, and special characters correctly.
Image → Base64
Convert images to Base64 data URLs online. Drop or select any image and copy the ready-to-paste data URI for CSS, HTML, or JSON.
Base32
Encode and decode Base32 strings online (RFC 4648). Handles TOTP / Google Authenticator secrets, DNSSEC records, and other case-insensitive binary-to-text formats. 100% local.
Base58
Encode and decode Base58 strings online — the alphabet used by Bitcoin addresses, Solana public keys, IPFS CID v0, and Flickr short links. 100% local, no padding, human-safe.
Punycode
Convert internationalized (IDN) domain names to and from their ASCII xn-- form. Follows RFC 3492 exactly — the same encoding your browser and DNS resolver use. 100% local.
Unicode Escape
Escape and unescape Unicode sequences online. Convert any text to \uXXXX / \u{XXXX} form, or reverse escape sequences back to readable text. Handles surrogate pairs and emoji. 100% local.