Base64 Encoder & Decoder
Encode text to Base64 or decode Base64 strings back to plain text, commonly used in web development and data transfer.
Related Tools
How to Use
- Enter Text or Base64 — Paste plain text to encode or a Base64 string to decode into the input field.
- Choose Encode or Decode — Select Encode to turn your text into Base64 or Decode to turn a Base64 string back into readable text. Tick URL-safe to use the - and _ alphabet without padding.
- Copy the Output — The result updates as you type (or click Encode / Decode). Use Copy or Download to save the result.
About the Base64 Encoder & Decoder
The Base64 Encoder & Decoder converts text to Base64 and back, updating as you type. It encodes the UTF-8 bytes of your text, so accented letters, CJK characters and emoji survive the round trip, and it can produce URL-safe Base64 for tokens and links. Developers use it to read or build HTTP Basic credentials, inspect the parts of a JSON Web Token, decode a data URI, and check what an API actually sent.
How it works
- Encode turns the text into UTF-8 bytes and writes each group of 3 bytes as 4 characters from A–Z, a–z, 0–9, + and /. A final group of 1 or 2 bytes is padded with == or =. The output is therefore about 133% of the input size; the panel shows the exact byte count and ratio. Text is encoded exactly as it appears in the box, including a final line break if there is one.
- URL-safe uses the alphabet from section 5 of RFC 4648: + becomes -, / becomes _, and the = padding is dropped, so the result can go into a URL path, query string or file name without further encoding.
- Decode accepts standard or URL-safe Base64, with or without padding, and ignores spaces and line breaks. You can paste a whole data URI (
data:text/plain;base64,…) or a PEM block; the prefix and the BEGIN/END lines are removed for you. If the decoded bytes are valid UTF-8 they appear as text. If not (an image or another binary file, for example), the tool tells you how many bytes it decoded and offers them as a download instead of showing garbled characters.
Worked examples
| Input | Mode | Result |
|---|---|---|
Man / Ma / M | Encode | TWFu / TWE= / TQ== |
Hello, World! | Encode | SGVsbG8sIFdvcmxkIQ== |
café (5 bytes: é is 2) | Encode | Y2Fmw6k= |
>>>??? | Encode / URL-safe | Pj4+Pz8/ / Pj4-Pz8_ |
😀 | Encode / URL-safe | 8J+YgA== / 8J-YgA |
data:text/plain;base64,SGk= | Decode | Hi |
/9j/4AAQ | Decode | Binary data, 6 bytes (the start of a JPEG file) |
Errors and edge cases
- A character outside the Base64 alphabet, such as @ or an = in the middle of the string, stops decoding with a message that names the character.
- A string that leaves exactly one character over when split into groups of four, such as
SGVsb, cannot be valid Base64 and is reported as truncated. - The encoder works on text you type or paste. To encode an image or other file you need its raw bytes, which this page does not read.
- Line breaks inside the input are part of the text when encoding:
Hellofollowed by a line break encodes toSGVsbG8K, notSGVsbG8=.
When to use it, and when not to
Base64 exists to carry bytes through channels built for text: email attachments (MIME), data URIs, JSON and XML payloads, PEM certificates and keys, and the HTTP Basic Authorization header, which is simply Base64 of username:password (user:pass becomes dXNlcjpwYXNz). That example is also the warning: Base64 is an encoding, not encryption. Anyone can decode it, so it never protects a password or secret. JSON Web Tokens use the URL-safe alphabet without padding for each dot-separated part, so you can paste a token's header or payload here, one part at a time, to read it. The Base64 guide walks through the algorithm bit by bit; for the %20 style of encoding used in links, use the URL Encoder & Decoder.
Encoding and decoding run in your browser, which matters when the string is a credential or token: nothing is sent to a server.
Frequently Asked Questions
What is Base64 encoding?
Base64 is a binary-to-text encoding scheme that represents binary data using a set of 64 printable ASCII characters (A-Z, a-z, 0-9, +, /). It is designed to carry binary data across systems that only support text, such as email (MIME) and JSON payloads.
Why does Base64-encoded data appear longer than the original?
Base64 encoding increases data size by approximately 33%. Every three bytes of input produce four Base64 characters. This overhead is the trade-off for ensuring the data can pass safely through text-only channels without corruption.
What are common use cases for Base64?
Base64 is used to embed images in HTML and CSS via data URIs, encode email attachments in MIME format, transmit binary data in JSON and XML APIs, store authentication tokens (e.g., HTTP Basic Auth headers), and encode cryptographic keys and certificates in PEM format.
Is Base64 a form of encryption?
No. Base64 is an encoding scheme, not an encryption algorithm. It does not provide confidentiality or security. Anyone with a Base64 decoder can reverse the encoding instantly. For secure data transmission, use proper encryption (AES, TLS) in combination with Base64 if needed.
Does the tool handle UTF-8 characters?
Yes. The encoder first converts the input text to its UTF-8 byte sequence and then Base64-encodes those bytes. The decoder reverses the process, correctly restoring multi-byte characters including accented letters, emojis, and CJK ideographs.
What is the difference between standard Base64 and URL-safe Base64?
Standard Base64 uses + and / as its 63rd and 64th characters, with = as padding. URL-safe Base64 replaces + with - and / with _, avoiding characters that have special meaning in URLs, and usually drops the = padding. Tick the URL-safe option to encode in that format; the decoder accepts either alphabet, with or without padding.