Encode text to Base64
Convert UTF-8 text to standard or URL-safe Base64. Works with emoji and any Unicode input. All processing runs locally.
SGVsbG8sIHdvcmxkIQpFbmNvZGUgYW55IFVURi04IHRleHQgw6LigqzigJ0gZW1vamkgw7DFuMWh4oKsIHdvcmsgdG9vLg==
How to encode Base64: a complete step-by-step guide
Base64 is the canonical text encoding for arbitrary bytes — defined in RFC 4648 and used everywhere from HTTP Basic Auth to data URIs to JWT segments. This encoder takes UTF-8 text, runs it through TextEncoder to get raw bytes, then maps each 3-byte group to 4 base64 alphabet characters via btoa. URL-safe mode applies the § 5 alternate alphabet for transport in URLs and headers.
- 01
Type or paste UTF-8 text
Drop in any Unicode string — ASCII, accented Latin, CJK ideographs, emoji, even mixed scripts. Native
btoa()only accepts Latin-1, so we route everything throughTextEncoder().encode()first to emit a faithful UTF-8 byte sequence before encoding.Need to encode a file (image, font, binary blob) instead of text? Use the Image to Base64 tool — it handles file readers and proper MIME prefixes for inline embedding.
UTF-8TextEncoderUnicodeemojibtoainput · plain text1 lineHello, world!
13 B · 13 charsutf-8 · ready - 02
Pick standard or URL-safe alphabet
Standard Base64 (RFC 4648 § 4) uses
A-Z a-z 0-9 + /with=padding. URL-safe Base64 (§ 5) substitutes-for+and_for/, optionally dropping padding — so the encoded string survives unescaped in URLs, JWT segments, cookies, and HTTP headers.If your downstream consumer is HTTP Basic Auth or a MIME body, leave URL-safe off. If you're encoding a token for a query parameter or composing a JWT, turn it on.
RFC 4648 § 5url-safepaddingJWT segmentalphabetalphabet · variantstandard+ / = → - _ (no padding)
alphabet setRFC 4648 - 03
Watch the live encoded output
The output panel updates on every keystroke — no submit, no debounce, no network. Each 3 input bytes expand to 4 output chars, giving a ~33% size overhead. Lengths not divisible by 3 are padded with
=in standard mode; URL-safe mode drops the trailing pad.To round-trip the result back to text, paste it into the Base64 Decoder, which handles both alphabets automatically.
live3:4 ratioRFC 4648 § 4client-sideround-tripoutput · base64+33% sizeSGVsbG8sIHdvcmxkIQ==
20 B · 1 lineencoded · ready - 04
Copy, download, or chain into another tool
Click Copy to send the result to your clipboard, or Download to save as
.txt. The encoded string is ASCII-only and safe for any byte-clean transport.Common follow-ups: feed the output into
data:URIs, build anAuthorization: Basicheader (btoa("user:pass")), or stitch base64url segments into a JWT with the JWT Encoder.clipboard.txtdata URIBasic authprivacy-firstexport · actions3 actions✓ Copied to clipboard ✓ Saved: base64.txt ✓ 100% client-side
ready to ship0 outbound
Encoding without surprises
Always UTF-8 first
Use TextEncoder / TextDecoder for bytes ↔ string conversion. btoa alone breaks on non-ASCII.
URL-safe vs standard Base64
Standard uses +, /, =; URL-safe swaps to -, _, no padding. Don’t mix them.
Hashes aren’t passwords
SHA-256 is fast; that’s good for fingerprints, bad for passwords. Use bcrypt / argon2 for credentials.
Watch padding rules
Some decoders are strict about = padding, others auto-pad. If round-trips fail at exactly 1 or 2 bytes, check padding.
Use Web Crypto for keys
Generate cryptographic keys via crypto.subtle, never Math.random. The latter is predictable.
JWT decode ≠ verify
Decoding a JWT just splits and base64-decodes. Verification needs the issuer’s public key / shared secret.
When to encode Base64
Auth tokens, data URIs, binary embedding.
Auth headers
HTTP Basic Auth uses Base64 of user:pass. Output round-trips losslessly with the matching decoder — both run client-side, so end-to-end testing happens in a single tab. Encoding flows through TextEncoder for predictable UTF-8 semantics.
RFC-compliantData URIs
Embed images/fonts inline in CSS/HTML. Web Crypto's subtle.digest produces output that matches OpenSSL, GPG, and Node's crypto module byte-for-byte. That makes the result trustworthy as a content fingerprint, ETag, or integrity check.
OpenSSL-matchedEmail attachments
MIME parts wrap binary in Base64. Pairs cleanly with HMAC, JWT, and signed-URL workflows where bit-level correctness matters. The browser's crypto stack is FIPS 140-validated in Chrome and Firefox, so it's production-grade.
losslessToken formats
JWT segments, OAuth state, CSRF nonces. Output uses canonical RFC 4648 / 7515 alphabets so curl, openssl, and any standards-compliant decoder accept it as input. URL-safe variants drop padding for tokens that travel in query strings.
byte-identicalURL params
URL-safe mode for tokens passed in query strings. Heavy hashing runs through useMemo so large inputs don't block typing. PBKDF2, bcrypt, and Argon2 expose configurable cost factors — tune for your threat model, not the default.
spec-gradeBinary in JSON
Send bytes through JSON-only APIs. Same input plus same options always yields identical bytes. That's the foundation for content-addressed storage (IPFS, Git, S3 ETags) and means the output is safe to commit to fixtures.
production-readyFrequently asked questions
Something missing?
Tell us what you need. We ship the top requests every two weeks.