Base64 Encode & Decode
Encode text or files to Base64 and decode Base64 back to text, files or JWTs, with URL-safe output. Runs in your browser.
Runs in your browser. Nothing is uploaded.
How to use the Base64 Encode & Decode
- Choose Encode or Decode, then type or paste text into the left box, or press Load example.
- The Base64 result appears on the right as you type.
- Tick URL-safe if the value will go into a URL, file name or token, or Wrap lines at 76 for email-style output.
- To encode an image or any other file, use Encode a file instead. You get a ready-to-use data URL.
- Copy the result or download it as a text file.
What Base64 encoding is for
Many systems were designed to carry plain text only: email bodies, JSON fields, HTML attributes, HTTP headers and environment variables. Raw binary data, or even some text characters, can be damaged or rejected on the way through. Base64 solves this by rewriting any sequence of bytes using just 64 safe characters: the letters A–Z and a–z, the digits 0–9, and two symbols. The result looks like gibberish, but it passes through text-only channels untouched and can be turned back into the exact original bytes.
Common uses
- HTTP Basic authentication, where
username:passwordis Base64-encoded into theAuthorizationheader - Data URLs that embed small images, icons or fonts directly in HTML, CSS or JSON
- Email attachments, which MIME encodes as Base64 wrapped at 76 characters per line
- Tokens and IDs such as JWTs, which use the URL-safe alphabet so they can sit in a link
- Storing binary data in JSON, which has no native binary type
How this encoder works
Your text is first converted to UTF-8 bytes, the encoding used by virtually every modern system, and
then those bytes are encoded. That means characters from every language, and emoji, round-trip
correctly. The URL-safe option switches to the - and _ alphabet and removes = padding, matching
RFC 4648 and the format used by JWTs. Wrap lines at 76 inserts line breaks the way email systems
expect.
For files, the tool reads the file locally and produces a complete data URL such as
data:image/png;base64,..., including the correct type, so you can paste it straight into an src
attribute or a CSS url(). Keep in mind that Base64 makes data about a third larger, so it is best for
small assets. Large images are usually better served as separate files.
Decoding Base64
Switch to Decode to turn Base64 back into readable text. Standard and URL-safe alphabets are both
accepted, with or without padding, and line breaks or spaces in pasted text are ignored. Data URLs
such as data:image/png;base64,… are understood, and a JWT is split into its header and payload.
When the bytes aren’t text, such as an image or a PDF, you get a preview where possible and a button
to download the file. Use the result as input and switch direction checks a round trip in one
click.
A note on security
Base64 is an encoding, not encryption. It offers no protection at all. Anyone who sees a Base64 string can decode it in seconds. That is also why this tool runs entirely in your browser: you may be encoding real credentials or private files, and nothing you enter is ever sent anywhere.
Frequently asked questions
Is Base64 a form of encryption?
No. Base64 only changes how data is written, not who can read it. Anyone can decode it instantly, so never rely on it to hide passwords or secrets.
Why is the Base64 output longer than my text?
Base64 represents every 3 bytes with 4 characters, so the output is about 33% larger than the input. Characters outside basic English take 2–4 bytes in UTF-8 before encoding, which adds more.
What is the difference between standard and URL-safe Base64?
Standard Base64 uses + and / and pads the end with =. Those characters have special meanings in URLs, so the URL-safe variant uses - and _ instead and usually drops the padding. JWTs use the URL-safe form.
Does it handle emoji and non-English text?
Yes. Text is converted to UTF-8 bytes first, so accents, Chinese, Arabic, Hindi and emoji all encode and decode correctly. The browser's built-in btoa function fails on such text, which is why many snippets online break.
Is my file uploaded when I encode it?
No. The file is read and encoded by your own browser. It never leaves your device, which also means encoding works offline once the page has loaded.
Tutorials
How to create a Basic Auth header with Base64
Build the Authorization header for HTTP Basic authentication by Base64-encoding a username and password, and test it with curl.
How to decode a JWT and read its payload
Decode a JSON Web Token in your browser to see its header and claims, such as user ID, role and expiry time, without sending the token anywhere.