Pikkola Base64, tool No. 29

Text into base64, and back, without leaving the tab.

Paste text, pick a format, read the result. Base64, URL-safe Base64, percent-encoding, hex and Unicode escapes all go both ways, and a dropped image comes out as a Data URI you can put into a stylesheet or an img tag. The work happens in the page, not on a server.

Open the converter No upload, no account
0
bytes uploaded
5
formats, both ways
UTF-8
not latin1
1
tab, no account
Hello, Pikkola Live
Text
Base64
Percent
Hex
Escape
One line of text, four encodings. converted in the tab

The converter

One text, five encodings, both directions

Type or paste on the left and the right side follows on every keystroke. Turn the arrow around and the same box reads base64, percent, hex or escapes back into text. Input that will not decode is named in a sentence rather than turned into silent question marks.

Format
Sample
Text 0 B · 0
Result 0 B · 0
0source bytes
0result bytes
0%size change

Nothing is sent. The page's security policy blocks every other origin. ⌘⏎ swaps sides · ⌘⇧C copies the result

Files and data URIs

An image becomes a line of text

Drop an image or a small file and it comes out as a Data URI, ready for a stylesheet, an img tag or a Markdown link. Paste a Data URI back in to see the picture and save the file. The browser reads the file and never sends it anywhere.

File to Data URI

Read with the FileReader API, encoded in this tab.

Drop a file, or choose one PNG, JPEG, SVG, WebP, GIF, PDF, WOFF. A few hundred kilobytes is comfortable.

What to paste where

Same bytes, five wrappers.


        

Data URI back to a file

Paste a data: URL or a bare base64 string. The type is read from the header, or guessed from the first bytes.

Nothing to show yet.

The five formats

What each one is for

The word hello, five ways. They carry the same bytes, and each one belongs somewhere different.

Format hello Where it belongs What to remember
Base64btoa / Buffer aGVsbG8= JSON fields, mail attachments, tokens A to Z, a to z, 0 to 9, plus and slash. Padding equals signs at the end.
Base64 URL-safeJWT, URL aGVsbG8 URLs, file names, JSON Web Tokens The same bytes with minus and underscore instead of plus and slash. Padding often dropped.
Percent-encodingencodeURIComponent hello Query strings, form posts, link values A space becomes %20. One UTF-8 byte above 0x7F becomes three characters like %EC%95%88.
Hexxxd, Wireshark 68 65 6c 6c 6f Byte dumps, colour values, protocol logs Two characters per byte. Case does not matter on the way in.
Unicode escape\uXXXX \u0068\u0065\u006c\u006c\u006f JavaScript strings, JSON, properties files One escape per UTF-16 unit, so an emoji takes two. The brace form writes it as one code point.

Base64 is encoding, not encryption. It keeps bytes intact through a text channel and anyone can read it. If the string has to stay secret, encrypt it first. If you only need to know it has not changed, a hash is the shorter answer.

Why this one

Small differences that cost you an afternoon elsewhere

UTF-8 first, always

Korean, Japanese and emoji are turned into UTF-8 bytes before encoding, which is what browsers, JSON and servers expect. The latin1 habit that turns a sentence into mojibake is not on offer here.

Errors with a subject

A base64 string of the wrong length, a stray character, an odd number of hex digits, bytes that are not UTF-8: each one is reported in a sentence, next to the box that caused it.

Both directions in one place

Decode is not a second page or a second tool. Turn the arrow around and the same text goes back, with padding and the URL-safe alphabet handled for you.

No upload. No account. No copy on a server.

The text lives in the textarea and the file in memory. Reload and it is gone, which is the point when the string is a key, a token or a customer record. Two preferences are kept in local storage: the theme and the interface language.

Read the privacy note

Questions

Asked while a string will not decode

Is Base64 encryption?

No. Base64 is a way to write bytes with 64 safe characters so they can travel through a text channel. Anyone holding the string can decode it in a second. If the text has to stay secret, encrypt it first. If you only need to know a file has not changed, a hash is the shorter answer.

Why is the encoded text longer than the original?

Base64 turns every 3 bytes into 4 characters, about 33 percent more, and adds one or two padding characters at the end. Percent-encoding can triple a Korean or Japanese character, because each one is 3 bytes in UTF-8 and each byte becomes a %XX group.

Why does Korean text turn into garbage in other tools?

Because they encode one character per byte. Korean, Japanese and emoji do not fit in a byte, so a latin1 encoder produces mojibake and the decode side cannot repair it. This tool converts the text to UTF-8 bytes first, which is what browsers, servers and JSON all expect.

What is URL-safe Base64?

The same bytes with the two characters that URLs dislike replaced: plus becomes minus and slash becomes underscore. The padding equals signs are often dropped, because a URL treats them as part of the path or query. JSON Web Tokens use this form.

When do I use percent-encoding instead of Base64?

When the string goes into a URL as a parameter or a path segment. Percent-encoding keeps the value readable and is what the URL standard defines. Base64 in a query string has to be percent-encoded anyway, because plus, slash and equals each mean something there.

How large a file can become a Data URI?

Any size the browser can hold, but a Data URI is about a third larger than the file and sits inside the document, so it suits small things: an icon, a logo, a texture, a short sound. Past a few hundred kilobytes a normal file link is better, and this page shows the encoded size before you paste it anywhere.

Are my files uploaded?

No. The browser's own file reader reads them and the page converts them in memory. The content security policy blocks requests to every other origin, so there is no route out even if a mistake were made.

Does it handle emoji and characters outside the basic plane?

Yes. Encoding works on UTF-8 bytes, so an emoji is four bytes and comes back as one character. In the escape format it is written as a surrogate pair by default, or as a single \u{1F600} when the brace option is on.