What is Base64 Encoding
Base64 is an encoding scheme that converts binary data into a string of 64 printable ASCII characters. It was designed to carry binary payloads across systems that only expect text, such as email bodies, JSON fields, HTTP headers and URLs. The algorithm groups the input into chunks of three bytes (24 bits) and splits each chunk into four groups of six bits. Each six bit value then maps to one of 64 characters: A to Z, a to z, 0 to 9 and the two symbols + and /. The output is padded with = characters when needed so the length is always a multiple of four.
The end result is a text form that is safe to transmit anywhere but is about 33 percent larger than the original binary. Decoding reverses the process: the tool reads four characters at a time, maps them back to the 24 bit chunk and splits that back into three bytes.
When Developers Use Base64
- Data URIs: embedding small images or fonts directly inside HTML, CSS or a JSON API response instead of a separate network request.
- Email attachments: MIME wraps any binary attachment in Base64 so SMTP servers can forward it as plain text.
- HTTP Basic Auth: the Authorization header encodes a username and password as Base64 after a single colon.
- JWT tokens: the three parts of a JSON Web Token are each Base64URL encoded JSON or signatures.
- Configuration secrets: Kubernetes Secrets, for example, store values as Base64 so YAML can carry arbitrary binary payloads.
- SSH keys and certificates: PEM files wrap the DER binary key in Base64 between BEGIN and END markers.
How to Use This Tool
- Pick a mode at the top: Encode to convert text to Base64, or Decode to turn a Base64 string back into text.
- Optionally enable URL-safe variant if your output will be placed inside a URL, cookie or filename.
- Paste your input in the text area. Any characters are allowed: letters, numbers, symbols, emoji and non-Latin scripts.
- Press the action button. The result appears in the dark output box below with a Copy shortcut.
- Use Swap to move the output into the input and reverse the operation, which is handy when round-tripping to verify a value.
Standard vs URL-safe Base64
Standard Base64 uses + and /. Both characters have reserved meaning in URLs: + represents a space and / separates path segments. Sending a raw Base64 token inside a query string without escaping will often corrupt it. The URL-safe variant defined in RFC 4648 Section 5 replaces + with a hyphen (-) and / with an underscore (_). Padding is sometimes also stripped. Enable the URL-safe option in this tool if your target is a URL path, a filename, a cookie value or a JWT.
Worked Example
The text Hello is five bytes: 72, 101, 108, 108, 111. Split into 6 bit groups that becomes 010010 000110 010101 101100 011011 000110 1111. Padded with trailing zeros to the next multiple of 6 and mapped to the alphabet, the output is SGVsbG8=. The single = at the end signals that the final group contained only one real byte, so one byte of padding was added during decoding.
Common Mistakes
- Pasting a Base64 string with newlines or extra whitespace and seeing a decode error. Most decoders tolerate this, including ours, but strict parsers will reject it.
- Forgetting to switch to URL-safe mode when the token is meant for a URL, which can produce decode failures on the receiving service.
- Using Base64 to hide secrets inside a public JavaScript bundle. The value is visible to anyone who opens DevTools.
- Confusing Base64 with Base32 or Base58. The alphabets and group sizes are different and the encodings are not interchangeable.
Privacy and Offline Use
The encode and decode functions in this page use the native browser JavaScript APIs TextEncoder, TextDecoder, btoa and atob. No input ever leaves your device. After the first load the page is cached by the browser, so you can even disconnect from the internet and keep using the tool.
Frequently Asked Questions
What is Base64 encoding used for?
Carrying binary data through text-only channels such as email, JSON APIs, HTTP headers and URLs without corruption.
Is Base64 encryption?
No. It is a public, reversible encoding. Anyone can decode a Base64 string in seconds. Use real cryptography for secrecy.
What is URL-safe Base64?
A variant that replaces + and / with - and _ so the encoded string can appear in URLs, cookies and filenames without extra escaping.
Why does the output end with = or ==?
Base64 processes three bytes at a time. When the input is not a multiple of three, one or two padding characters are added to keep the output length a multiple of four.
Does this tool support Unicode and emoji?
Yes. Input is encoded to UTF-8 first, which handles emoji, Arabic, Chinese, Hindi and every other script correctly.
How large a string can I encode here?
Only your device memory limits it. Several megabytes work smoothly on modern phones and laptops.
Is my data sent to a server?
No. Every conversion happens inside your browser. Nothing is uploaded, logged or stored.