Base64 Encoding and Decoding Guide
Base64 is a binary-to-text encoding scheme that represents binary data using only 64 printable ASCII characters (A–Z, a–z, 0–9, +, /). It's one of the most widely used encoding schemes in web development, used for data URIs, email attachments, JSON API payloads, JWT tokens, and Basic HTTP authentication. Our free online Base64 encoder and decoder converts text instantly in your browser.
How Base64 Encoding Works
Base64 works by taking 3 bytes (24 bits) of binary data and splitting them into four 6-bit groups. Each 6-bit group maps to one of 64 printable characters. If the input isn't divisible by 3, padding characters (=) are added. This means Base64 output is always 4 characters per 3 bytes of input — a 33% size increase compared to the original binary data.
Common Uses of Base64
Data URIs: Embed images, fonts, and other files directly in HTML/CSS without separate HTTP requests. Email (MIME): Email attachments and inline images use Base64 to safely encode binary files within the text-based email format. JSON APIs: Since JSON is text-based, binary data (files, images, audio) must be Base64-encoded to be included in a JSON payload. JWT (JSON Web Tokens): The header and payload sections of JWTs are Base64url-encoded (a URL-safe variant). Basic Authentication: HTTP Basic Auth encodes "username:password" in Base64 — though this is not encryption.
Base64 vs Encryption
Base64 is purely an encoding scheme — it does NOT provide security or privacy. Anyone can decode Base64 instantly. It is often confused with encryption because the output looks scrambled, but there is no key and no security. Never use Base64 to protect sensitive information. Use proper encryption (AES, RSA) for that purpose.
Using Our Free Base64 Encoder/Decoder
Enter text in the encode field to get Base64 output, or paste Base64 in the decode field to get the original text. Conversion is instant and happens entirely in your browser.
Frequently Asked Questions
What is Base64 encoding?
Base64 converts binary data into printable ASCII text using 64 characters (A-Z, a-z, 0-9, +, /). It encodes 3 bytes as 4 characters, increasing size by ~33%. Used for data URIs, email attachments, JWT tokens, and API payloads.
Is Base64 secure or encrypted?
No. Base64 is just an encoding — not encryption or security. Anyone can decode Base64 instantly. It's often confused with encryption because the output looks garbled. For security, use proper encryption algorithms (AES, RSA).
What is the difference between Base64 and Base64url?
Standard Base64 uses + and / characters, which have special meanings in URLs. Base64url replaces + with - and / with _, making it safe to use in URLs and filenames without percent-encoding. JWT tokens use Base64url.
How do I decode a Base64 string in JavaScript?
Use atob() to decode: atob('SGVsbG8=') returns 'Hello'. To encode, use btoa(): btoa('Hello') returns 'SGVsbG8='. Note: atob/btoa only work with binary strings; for Unicode, additional encoding steps are needed.