Base64 Encoder/Decoder
Encode or decode text and files to/from Base64 format, with URL-safe Base64 support.
Frequently Asked Questions
What is Base64 encoding?
Base64 converts binary data into a text-safe ASCII string using 64 printable characters (A-Z, a-z, 0-9, +, /). It's used to embed binary data in text-based formats like JSON, HTML, CSS, and email. Tip: Base64 encoding increases the data size by approximately 33%, so it's best suited for small assets.
When should I use Base64 encoding?
Common uses include embedding small images as data URIs in CSS/HTML (saving HTTP requests), encoding binary data for JSON APIs, and encoding file attachments in email (MIME). Tip: for images under 2-5 KB, Base64 data URIs are often faster than separate HTTP requests due to reduced round-trips.
Is Base64 encryption?
No. Base64 is an encoding scheme, not encryption. Anyone can decode Base64 text back to the original data instantly. Never use Base64 to 'hide' passwords, tokens, or sensitive information. Tip: if you need to protect data, use proper encryption (AES, RSA) or hashing (SHA-256) — not encoding.
What is the difference between Base64 and Base64url?
Standard Base64 uses + and / characters which are unsafe in URLs. Base64url replaces them with - and _ and omits padding (=). It's used in JWTs, URL parameters, and filename-safe contexts. Tip: most modern libraries support both variants — check your runtime docs for URL-safe options.
How do I Base64 encode in JavaScript?
Use btoa() and atob() for simple strings, or the Buffer API in Node.js: Buffer.from(str).toString('base64'). For binary data or Unicode strings, first encode to Uint8Array with TextEncoder, then convert. Tip: btoa() only handles Latin-1 characters — for Unicode text, encode to UTF-8 bytes first.