Developer tools · Base64
Encode text as Base64.
Convert UTF-8 text to standard Base64 or decode a Base64 text value. Base64 is an encoding format, not encryption.
Read the quick guideRuns in your browser
Encoding and decoding stay on this device. Your text is not sent to TeachyLeaf.
Free online tool
Base64 text encoder and decoder
Enter text or standard Base64, then choose an operation.
A practical guide
Base64 represents bytes as text.
Use Base64 when a format needs binary data represented with a limited text alphabet—not to keep information secret.
A checked example
The ASCII text Hello, TeachyLeaf! becomes SGVsbG8sIFRlYWNoeUxlYWYh. Encoding and decoding that value returns the original text.
Why Unicode needs a byte step
JavaScript's btoa() expects each character to fit in a single byte; passing many non-ASCII characters directly can throw an error. For text, first convert it to UTF-8 bytes with TextEncoder, then map those bytes to a binary string for btoa(). To reverse the process, use atob(), convert its byte values to a Uint8Array, and decode them with TextDecoder.
const bytes = new TextEncoder().encode("café 🌿");
const binary = Array.from(bytes, byte => String.fromCharCode(byte)).join("");
const base64 = btoa(binary);
For larger text, build the binary string in chunks rather than spreading an unbounded byte array into one function call. The interactive tool uses chunked conversion.
Encoding is not encryption
Anyone with a Base64 value can decode it. Do not use Base64 to protect passwords, tokens, personal information, or other secrets. Use an appropriate encryption design when confidentiality is required.
What this tool supports and does not support
This tool converts text through UTF-8 and standard Base64 using browser APIs. It accepts standard Base64 with optional correct padding and ignores ASCII whitespace while decoding. It does not accept the URL-safe Base64 alphabet (- and _), process binary files, validate application data, or encrypt content. Decoding also requires the bytes to represent valid UTF-8 text.
Continue learning
Read the JavaScript Base64 and Unicode lesson, then explore the JSON formatter or URL component tool.
Is my input uploaded or stored?
No. Conversion happens locally in your browser. This tool does not submit your text to TeachyLeaf.
Why does decoding fail for some Base64 values?
The value may use the URL-safe alphabet, have invalid padding, or decode to bytes that are not valid UTF-8 text. This tool is for standard Base64 text, not arbitrary binary data.
Can I use Base64 to hide a secret?
No. Base64 is reversible encoding and does not provide confidentiality.