Base64 Encode / Decode
Encode and decode UTF-8-safe Base64 strings.
UTF-8 safe: Chinese, emoji and other multi-byte characters work correctly.
Base64 output
Base64 length
28 chars
Byte size
19 bytes
input: 19 bytes
SGVsbG8sIOS4lueVjCEg8J+Riw==
Details
- Direction
- Text → Base64
- Character encoding
- UTF-8
- Input size
- 19 bytes
- Output size
- 19 bytes
Encoding uses UTF-8 before Base64, so multi-byte characters like 中文 and emoji round-trip correctly — a common pitfall with naive btoa/atob implementations. Everything runs in your browser; nothing is uploaded. Note that Base64 is an encoding, not encryption: anyone can decode it back.
How to use the base64 encode / decode
The Base64 encoder and decoder converts text into Base64 and back. Base64 is the standard way to represent binary-safe data as plain ASCII text — every email attachment, data URL, JWT token, anddata: URI you meet online is built on it. This tool does both directions instantly, with correct UTF-8 handling so Chinese, emoji, and other multi-byte characters survive the round trip.
Type or paste text in the input, choose encode or decode, and the output updates as you type. Everything runs in your browser — nothing is uploaded, logged, or stored.
What Base64 actually is
Base64 takes every 3 bytes of input and rewrites them as 4 printable characters from a 62-character alphabet (A–Z, a–z, 0–9, plus + and /, with = as padding). The result is about 33% larger than the original, but it contains only characters that survive any transport channel that might mangle binary data — email systems, URLs, XML, plain-text protocols.
That is the core trade: Base64 makes data portable at the cost of size. You use it when a channel cannot carry raw bytes — embedding a small image directly in CSS, putting a file into a JSON field, passing binary through an environment variable, or constructing the middle section of a JWT.
Why UTF-8 handling matters
The classic pitfall: JavaScript's built-in btoa() function only handles Latin-1 characters. Pass it Chinese text or an emoji and it throws an error — or worse, in naive implementations, silently corrupts the string. This tool encodes with UTF-8 first, then applies Base64, so Hello, 世界! 👋 encodes and decodes back to exactly the same text. If you have ever seen a "character out of range" error from a quick one-liner, this is the problem it causes.
The same care applies in reverse: decoding produces UTF-8 bytes and decodes them as text, so multi-byte characters come back intact rather than as mojibake.
Error reporting
Decoding invalid input fails loudly. The tool checks the character alphabet and the length (Base64 must be a multiple of 4 characters after whitespace is stripped) before decoding, and reports a clear message instead of returning garbled output. Whitespace and line breaks inside the input are ignored, because real-world Base64 — PEM blocks, MIME bodies, wrapped API responses — is routinely line-wrapped.
Common uses
Developers encode a short string to build a Basic-auth header, decode a JWT payload to inspect its claims, or embed an SVG as a data URL. Engineers verify checksums and tokens by round-tripping them through the tool. Analysts decode Base64 fields found in logs or API responses. The reverse direction — decoding — is just as common, since much of Base64 you encounter in the wild was produced somewhere else.
Encoding is not encryption
The most important caveat: Base64 is an encoding, not a security measure. Anyone can decode it in one line, so never treat a Base64-encoded password, API key, or token as hidden. It protects data integrity across text-only channels — nothing more. If you need actual confidentiality, use proper encryption.
Frequently asked questions
Is Base64 the same as encryption?
No. Base64 is an encoding, not encryption — anyone can decode it trivially. It exists to make binary data safe for text-only channels like email or URLs, not to hide information. Never store passwords or secrets as 'protected' Base64.
Why is Base64 about 33% larger?
Every 3 bytes of input become 4 characters of output, so 4/3 = 1.33×. The size increase buys portability: the output contains only ASCII characters that pass through any transport without corruption.
Why does my tool fail on Chinese or emoji text?
Because many simple implementations call btoa() directly, which only accepts Latin-1. This tool encodes as UTF-8 first, then applies Base64, so multi-byte characters round-trip correctly in both directions.
What do I do with input that has line breaks?
Nothing — the decoder strips all whitespace automatically. PEM blocks, MIME bodies, and wrapped API responses are commonly line-wrapped, and all of them decode correctly here.
Is my text uploaded anywhere?
No. Encoding and decoding happen entirely in your browser using the native TextEncoder, TextDecoder, btoa and atob functions. Nothing is transmitted or stored.
Related calculators
View allWhy use CalcFacts?
- Every calculation runs in your browser — nothing is uploaded.
- No signup, no paywall, no email required.
- Clear formulas and breakdowns you can verify yourself.
- Built for speed: results update as you type.