How to use
- Choose Encode or Decode at the top of the tool.
- Type or paste your text, or click Open file to encode any file.
- Adjust the variant (standard or URL-safe), padding, line wrap or text encoding if needed. The result updates as you type.
- Copy the result, download it, or press Swap to send it back through the opposite direction.
What is Base64?
Base64 is a binary-to-text encoding that represents any sequence of bytes with 64 printable ASCII characters: A-Z, a-z, 0-9, + and /, with = used for padding. It lets binary data such as images, keys or compressed files travel safely through systems that were designed for text, like email, JSON, XML, URLs and HTML.
The encoder reads the input three bytes (24 bits) at a time and splits them into four groups of 6 bits. Each 6-bit value, from 0 to 63, selects one character of the alphabet. When the input length is not a multiple of three, the last group is padded with one or two = signs. As a result, Base64 output is always about 33% larger than the original data.
Base64 is an encoding, not encryption. Anyone can decode it, so never use it to hide passwords or secrets.
Base64 and Base64URL
Standard Base64 uses + and /, which have special meanings in URLs and file names. Base64URL, defined in RFC 4648 section 5, replaces them with - and _ and usually drops the padding. It is used by JSON Web Tokens, OAuth and anywhere a value must sit inside a URL. The decoder on this page accepts both forms automatically.
| Standard Base64 | Base64URL | |
|---|---|---|
| Characters 62 and 63 | + / | - _ |
| Padding | Required = | Optional, usually omitted |
| Safe in URLs and file names | No | Yes |
| Typical use | Email (MIME), data URIs, JSON, PEM keys | JWT, OAuth, URL parameters |
Common uses of Base64
- Email attachments. MIME encodes attachments as Base64 wrapped at 76 characters per line. Use the Line wrap option to reproduce this format.
- Embedding images and files. Data URIs put small images, fonts or icons directly into HTML and CSS. See Image to Base64 and Base64 to Image.
- APIs and configuration. JSON has no binary type, so APIs send files, signatures and keys as Base64 strings. Kubernetes Secrets store their values in Base64 as well.
- Authentication. HTTP Basic authentication sends
username:passwordas Base64, and JSON Web Tokens are three Base64URL segments. - Certificates and keys. PEM files are Base64-encoded DER data wrapped at 64 characters per line.
Base64 in programming languages
| Language | Encode | Decode |
|---|---|---|
| JavaScript (browser) | btoa(binaryString) | atob(base64) |
| Node.js | Buffer.from(str).toString('base64') | Buffer.from(b64, 'base64').toString() |
| Python | base64.b64encode(data) | base64.b64decode(data) |
| PHP | base64_encode($str) | base64_decode($b64) |
| Java | Base64.getEncoder().encodeToString(bytes) | Base64.getDecoder().decode(b64) |
| C# | Convert.ToBase64String(bytes) | Convert.FromBase64String(b64) |
| Go | base64.StdEncoding.EncodeToString(b) | base64.StdEncoding.DecodeString(s) |
| Shell | base64 file.bin | base64 -d file.txt |
In browsers, btoa only accepts characters up to U+00FF. To encode Unicode text, convert it to UTF-8 bytes first, for example with TextEncoder, or use this tool, which encodes text as UTF-8 by default.
More than Base64
Base64.is also covers the rest of the Base-N family: Base32, Base58, Base62, Base85, Ascii85, basE91, Base45, hex and binary. If you are not sure which encoding a string uses, try the encoding detector, or compare all of them at once with All Encodings.
Specification
| Alphabet | A-Z a-z 0-9 + / |
|---|---|
| Output size | 4 characters per 3 bytes (about 133%) |
| Padding | = to a multiple of 4 characters |
| Standard | RFC 4648 section 4 |
| Case sensitive | Yes |
Examples
| Input (UTF-8) | Output |
|---|---|
Hello, World! | SGVsbG8sIFdvcmxkIQ== |
Base64.is | QmFzZTY0Lmlz |
你好 | 5L2g5aW9 |
Frequently asked questions
Is my data uploaded to a server?
No. Encoding and decoding run entirely in your browser with JavaScript. The text and files you enter never leave your device, and the tool keeps working offline once the page has loaded.
Why does the decoded text look garbled?
What do the equals signs at the end mean?
They are padding. Base64 works in blocks of four characters, and = fills the last block when the input length is not a multiple of three bytes. One = means the last block encodes two bytes, two mean it encodes one byte.
How much bigger does data get when encoded?
Base64 turns every 3 bytes into 4 characters, so the output is about 33% larger than the input, plus line breaks if you enable line wrapping.
Is Base64 a form of encryption?
No. Base64 only changes how data is represented. It has no key and anyone can decode it, so use real encryption such as AES or TLS to protect sensitive information.