All tools / Base64 Encode & Decode

Base64 Encode & Decode

Encode text to Base64 or decode Base64 back to text with correct UTF-8 handling, in standard or URL-safe form. Turn files and images into Base64 or data URIs, and turn Base64 back into a downloadable file. Runs in your browser.

Base64
Type text above to see its Base64.

How to use the Base64 encoder and decoder

On the Text tab, choose Encode and type or paste text; the Base64 appears as you type. Choose Decode to turn Base64 back into readable text. Tick URL-safe if the result goes into a URL, file name or token. Swap moves the result into the input so you can check a round trip.

To embed an image or send a file through a text-only channel, use File → Base64 and pick the file. Choose Data URI to get a string you can paste straight into HTML or CSS. To go the other way, paste Base64 or a data URI on the Base64 → File tab and press Download file. The type (PNG, JPEG, PDF, ZIP and others) is detected for you.

Example

The text Mabuhay ñ is 10 bytes in UTF-8 (the ñ takes two bytes), so its Base64 is TWFidWhheSDDsQ==. The two = signs pad the end to a multiple of 4 characters. In URL-safe form without padding it becomes TWFidWhheSDDsQ. Decoding either one gives back Mabuhay ñ.

Base64 turns every 3 bytes into 4 characters, so encoded data is about 33% larger than the original. A 30 KB logo becomes roughly 40 KB of text.

Frequently asked questions

Is my text or file uploaded anywhere?

No. Encoding and decoding happen in your browser with JavaScript. Nothing you type, paste or open is sent to a server, so it is safe to use with private data.

What is the difference between standard and URL-safe Base64?

Standard Base64 uses the characters + and / and pads the end with =. Those characters have special meanings in URLs and file names, so URL-safe Base64 (RFC 4648 section 5) uses - and _ instead and usually drops the padding. JSON Web Tokens use the URL-safe form. When decoding, this tool accepts both automatically.

Why does my decoded text show strange characters in other tools?

Base64 stores bytes, not letters. Text such as "ñ" or emoji has to be turned into bytes first, and almost every system uses UTF-8 for that. Some simple tools use the browser function btoa directly, which fails or gives wrong results on non-English text. This tool always uses UTF-8, so "Mabuhay ñ" round-trips correctly.

What is a data URI?

A data URI puts a whole file inside a single text string, for example data:image/png;base64,iVBORw0... You can paste it into an HTML img src or a CSS background-image to embed a small image without a separate file. It is best for small icons; large files make your page heavier because Base64 is about 33% bigger than the original.

Why wrap lines at 76 characters?

Email (MIME) and PEM files such as certificates limit Base64 lines to 76 or 64 characters. Most other uses, such as JSON, URLs and data URIs, expect one long line, so wrapping is off by default. Line breaks are ignored when decoding.