Base64 Encode & Decode
Simple text
JSON data
HTML snippet
Encode or decode Base64 strings instantly in your browser. Supports text and file input. Free, private, no data sent to servers.
How to Use Base64 Encode & Decode
- Select whether you want to Encode or Decode.
- Paste or type your text in the input area.
- The result appears instantly in the output area.
- Click "Copy" to copy the result to your clipboard.
What is Base64 Encoding?
Base64 is a binary-to-text encoding scheme that converts binary data into a string of printable ASCII characters. It was originally designed to allow binary data to be transmitted over protocols that only support text, such as SMTP (email) and HTTP. The encoding maps every 3 bytes of input into 4 ASCII characters drawn from an alphabet of 64 characters: uppercase letters (A-Z), lowercase letters (a-z), digits (0-9), plus (+), and slash (/). The equals sign (=) is used for padding when the input length is not a multiple of three.
How Base64 Encoding Works
The encoding process takes three bytes (24 bits) of input at a time and splits them into four 6-bit groups. Each 6-bit value (ranging from 0 to 63) is then mapped to one of the 64 characters in the Base64 alphabet. If the input is not evenly divisible by three bytes, padding characters are appended: one = if there are two remaining bytes, or two == if there is one remaining byte. Decoding reverses this process by converting each Base64 character back into its 6-bit value and reassembling the original bytes. Because every 3 bytes become 4 characters, Base64 encoded data is always approximately 33% larger than the original input.
Common Use Cases
- Embedding images directly in HTML or CSS using data URIs
- Encoding binary attachments in email (MIME) messages
- Transmitting binary data inside JSON or XML payloads
- Encoding credentials in HTTP Basic Authentication headers
- Storing small binary blobs in text-only databases or configuration files
- Encoding cryptographic keys and certificates in PEM format
Base64 vs URL Encoding
Base64 and URL encoding solve different problems and should not be confused. Base64 converts binary data into a text-safe representation. URL encoding (percent-encoding) replaces characters that have special meaning in URLs with %HH sequences. Standard Base64 uses +, /, and =, which are all special characters in URLs. That is why a variant called Base64URL exists, replacing + with - and / with _, and dropping the padding. This variant is used in JWTs and many web APIs. It is important to note that Base64 is not encryption. Anyone can decode a Base64 string without a key. Never use Base64 to hide sensitive information; use proper encryption instead.
In JavaScript, you can encode and decode Base64 using btoa() and atob() for ASCII strings. For Unicode text, you need to first encode to UTF-8 bytes before Base64-encoding, typically using TextEncoder and TextDecoder. In Node.js, the Buffer class handles both ASCII and UTF-8 Base64 encoding natively.
For encoding special characters in URLs, try our URL Encode/Decode tool. You can also inspect authentication tokens with the JWT Decoder, convert special characters for HTML with the HTML Entity Encoder, or generate a SHA-256 Hash for data integrity verification.