My Tool Studio
Developer

Base64 Decode and Encode

This tool lets you base64 decode a string back into readable text, or encode text to Base64, right in your browser. Paste on the left and click Decode or Encode, or turn on Live mode to convert as you type. Pick a character set such as UTF-8, Windows-1252, ISO-8859-1 or Shift_JIS, or let Auto-detect choose when decoding. Decoding accepts standard Base64 and base64url, adds missing = padding, ignores line breaks and strips a data: URI prefix. You can also convert each line separately and wrap output at 76 characters for MIME. The File or image tab turns any file into Base64, or a Base64 string back into a file with an image preview. Nothing you paste or open is sent to a server.

Always freeNo sign upRuns in your browser

How to use

01

Paste text or choose a file

Put a value in the Input pane on the Text tab, or open the File or image tab to encode a file up to 100 MB. Try sample loads a line with an accented letter and an emoji.

02

Set options, then Encode or Decode

Choose the Character set, and tick URL-safe output, Each line separately or 76-character lines if you need them. Click Encode or Decode, or tick Live mode so the output follows your typing.

03

Copy, download or swap

Copy the result, download it as a .txt file, or click Swap to send the output back to the input. For a decoded file, check the preview, rename it and click Download file.

Why Base64 Decode and Encode

How Base64 works: Man becomes TWFu

Base64 reads the input 3 bytes (24 bits) at a time and splits those bits into four 6-bit groups. Each group is a number from 0 to 63, and each number maps to one of 64 characters: A to Z, a to z, 0 to 9, then two extra symbols.

The word Man is the bytes 77, 97 and 110, or 01001101 01100001 01101110 in binary. Regrouped into 6 bits that is 010011 010110 000101 101110, which are the numbers 19, 22, 5 and 46. Those map to T, W, F and u, so Man encodes to TWFu. If the input were only Ma, there would be 2 bytes, the last group would be padded, and the output would be TWE=.

The two extra symbols are where the standard and URL-safe versions differ:

Base64 (RFC 4648)base64url
Characters for 62 and 63+ and /- and _
Padding= or == at the endUsually left off
Safe in a URL as isNo, + and / need escapingYes
Typical usesEmail attachments, data URIs, Basic authJWTs, URL parameters, file names

Character sets: when UTF-8 is not the answer

Base64 only carries bytes. Turning those bytes into letters needs a character set, and most modern data uses UTF-8, which is the default here. Older systems, email archives and some Windows or Japanese software used other sets, and decoding their bytes as UTF-8 gives errors or odd symbols.

Auto-detect tries UTF-8 first, then a UTF-16 byte order mark, then Windows-1252 so every byte still shows as a character. Multi-byte East Asian sets can be decoded but not encoded, because browsers only include decoders for them.

Character setWhere you meet it
UTF-8Almost everything today: web pages, JSON, APIs
Windows-1252 / ISO-8859-1Old Western European text, legacy databases, some CSV exports
UTF-16LEWindows internals, PowerShell -EncodedCommand values
Shift_JIS, EUC-JPOlder Japanese email and files (decode only)
GB18030, Big5Older Chinese text (decode only)
KOI8-R, Windows-1251Older Russian text

Common questions

Why does my Base64 string end with = or ==?
Base64 turns every 3 bytes of input into 4 characters. When the input length is not a multiple of 3, the last group is padded: one = means the final group held 2 bytes, and == means it held 1 byte. This decoder works with or without the padding.
What is the difference between Base64 and Base64URL?
Base64URL swaps + for - and / for _ so the result is safe in URLs and file names, and it usually drops the = padding. JWTs use it. Tick URL-safe output to encode in that form; Decode accepts both alphabets without any setting.
Why does Base64 decoding give garbled characters?
The bytes were probably saved in another character set, or they are not text at all. Pick the right set under Character set, such as Windows-1252 for old Western text or Shift_JIS for Japanese, or choose Auto-detect. If the data is an image, PDF or ZIP, the tool says so and offers to open it in the File or image tab.
How much bigger does Base64 make my data?
About a third bigger. Every 3 bytes become 4 characters, so 300 bytes of input become 400 characters of output, plus up to two = signs. Ticking 76-character lines adds a line break every 76 characters, as email (MIME) requires, which adds a little more.
How do I decode Base64 on the command line?
On Linux and recent macOS versions, run echo TWFu | base64 -d (older macOS versions use -D). In Windows PowerShell, run [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('TWFu')). Both print Man.
Is Base64 a form of encryption?
No. It is a reversible encoding with no key, so anyone who has the string can decode it. Never rely on Base64 to hide passwords, API keys or personal data.
Can I decode a Base64 image or file with this tool?
Yes. Paste the Base64 or data URI into Base64 to file or image on the File or image tab and click Decode to file. The tool reads the first bytes to spot PNG, JPEG, GIF, WebP, SVG, PDF, ZIP and other common types, shows a preview for images, and lets you download the file with the right extension.
How do I Base64 encode or decode many values at once?
Tick Each line separately. Every line is converted on its own and blank lines are kept, so a column copied from a spreadsheet comes back in the same order. A line that fails is named by its line number in the error, and the other lines still convert.
Can this decode the Base64 part of a data URI?
Yes. Paste the whole data URI and the data:...;base64, prefix is removed before decoding. Text types such as SVG or JSON show as text on the Text tab, and binary types such as PNG decode on the File or image tab, where the type in the prefix also helps name the file.
How do I build a Basic auth header with Base64?
Type username:password, click Encode, and put the result after the word Basic. For user:pass the header is Authorization: Basic dXNlcjpwYXNz. Anyone who sees the header can decode it, so only send it over HTTPS.

More Developer tools

View all