How to encode or decode Base64
- Choose Encode or Decode.
- Type or paste your text. The result updates as you type.
- Tick URL-safe if the output will go into a URL or token.
- Click Copy. To embed an image or file, open "Encode a file" to get a data URL.
What is Base64 used for?
Base64 turns binary data into plain ASCII text so it can travel through systems designed for text. Common uses include email attachments (MIME), embedding small images in CSS or HTML as data: URLs, HTTP Basic authentication headers, storing binary values in JSON, and the header and payload of JSON Web Tokens.
Decoding errors
If decoding fails, check for characters outside the Base64 alphabet (A–Z, a–z, 0–9, +, /, =), or a string that was cut off. Spaces and line breaks are ignored automatically, and both standard and URL-safe alphabets are accepted.
Related: URL Encoder, JWT Decoder, JSON Formatter.
How Base64 works
Base64 takes the binary data, splits it into groups of 3 bytes (24 bits), and represents each group as 4 characters from a 64-character alphabet: A–Z, a–z, 0–9, + and /. When the data length is not a multiple of 3, one or two = characters are added as padding. That is why encoded text is about a third longer than the original and often ends with = or ==.
Base64 examples
hello→aGVsbG8=user:password→dXNlcjpwYXNzd29yZA==(used in HTTP Basic auth headers)- Emoji and non-English text are encoded as UTF-8 bytes first, so
ébecomesw6k=.
Data URLs for images
The file encoder creates a data URL like data:image/png;base64,iVBOR…, which can be placed directly into an <img src>, a CSS background-image or an email template. Embedding is useful for tiny icons, but for anything larger than a few kilobytes a normal image file is better, because Base64 makes it bigger and stops the browser from caching it separately.
Security note
Seeing Base64 in a URL or cookie does not mean the data is protected. Decoding is trivial, as this tool shows. Sensitive information must be encrypted, and passwords must be hashed with an algorithm designed for passwords, never just encoded.
Base64 in code
- JavaScript (browser):
btoa()andatob()work only with Latin-1; for Unicode useTextEncoderas this tool does. - Node.js:
Buffer.from(text).toString('base64') - Python:
base64.b64encode(data)andbase64.urlsafe_b64encode(data) - Command line:
base64on macOS and Linux,certutil -encodeon Windows.
Frequently asked questions
Is Base64 encryption?
No. Base64 is an encoding, not encryption. Anyone can decode it, so never use it to protect passwords or secrets.
What is URL-safe Base64?
Base64URL replaces "+" with "-" and "/" with "_" and drops the "=" padding, so the result can be used in URLs, file names and JWTs without escaping.
Does it handle emoji and non-English text?
Yes. Text is encoded as UTF-8 first, so accented letters, Chinese, Arabic and emoji round-trip correctly.
Why does Base64 make data bigger?
Base64 represents every 3 bytes as 4 characters, so encoded data is about 33% larger than the original.