Skip to contentSkip to the inputSkip to the result

UTF-8 Base64 encoder

Encode Korean, emoji and other Unicode text as Base64.

Loading tool

Instructions

UTF-8 Base64 encoder

How to use

  1. Choose encode or decode.
  2. Enter plain text or a Base64 value and convert.

Supported input

  • Standard or URL-safe Base64 of UTF-8 text.
  • Missing padding and data: prefixes are accepted when decoding; data that is not text can be saved as a file.

Input example

한글

Result example

7ZWc6riA

Troubleshooting

  • Check required inputs, numeric ranges and the selected conversion direction.

How it works

  • Encode Korean, emoji and other Unicode text as Base64.

How Base64 turns bytes into text, and why a decode is refused

Where you run into it

  • HTTP Basic authentication, where "user:password" travels Base64-encoded in the Authorization header
  • data: URLs that inline a small icon or font straight into CSS or HTML
  • Email attachments, since mail was built to carry text and binary files are sent as lines of Base64
  • JSON Web Tokens, whose first two dot-separated parts are JSON written in URL-safe Base64
  • Configuration that has to hold raw bytes as text, such as the data fields of a Kubernetes Secret

Three bytes in, four characters out

The encoder takes the input 24 bits (three bytes) at a time and cuts each group into four 6-bit pieces. Each piece is a number from 0 to 63, written as one of A–Z, a–z, 0–9, + and /. Sixty-four symbols, hence the name.

Walk through "Hi!" by hand: H is 0x48, i is 0x69 and ! is 0x21. Their 24 bits split into 010010 000110 100100 100001, which are 18, 6, 36 and 33, the letters S, G, k and h. The tool gives SGkh. When the last group has only two bytes the output ends with one =, and with one byte it ends with two: Ma becomes TWE= and M becomes TQ==.

Worked example: a Basic auth header

  1. 1Take the example from RFC 7617: user Aladdin, password open sesame, joined with a colon as Aladdin:open sesame.
  2. 2Encoding gives QWxhZGRpbjpvcGVuIHNlc2FtZQ==, exactly the value printed in the RFC.
  3. 3The header is then Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==.
  4. 4Anyone who sees that header can decode it and read the password, which is why Basic authentication only belongs on HTTPS.

What the two options change

  • URL-safe (- _) swaps + for - and / for _ and leaves off the trailing = padding, as RFC 4648 section 5 describes and as JWTs use it. The header {"alg":"HS256","typ":"JWT"} encodes to eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9 either way: at 27 bytes it needs no padding and happens to contain no + or /.
  • Line breaks every 76 characters follow the MIME rule in RFC 2045. Forty copies of the Korean syllable 가 are 120 bytes in UTF-8, so 160 characters of Base64, split into lines of 76, 76 and 8. The tool separates lines with LF only; raw mail wants CRLF, so fix the line endings if you paste the result into a message source by hand.

Forgiving on input, strict on meaning

Decoding accepts the usual damage from copy and paste. Spaces and line breaks inside the text are dropped (SGVs bG8= gives Hello), missing padding is restored (QQ gives A, TWE gives Ma), and a prefix such as data:text/plain;base64,SGk= is removed before decoding to Hi.

What it will not do is accept text that no correct encoder would produce. A lenient decoder such as atob reads QR== as A, but A encodes back to QQ==: the leftover bits that should be zero are not. RFC 4648 section 3.5 allows decoders to reject such non-canonical input, and this one does. Likewise, if the bytes are not valid UTF-8, as with gA== (a lone 0x80 byte), it stops rather than showing a replacement character. If another site decodes a string that fails here, one of these two reasons is usually why.

Checked

Frequently asked questions

How much bigger does Base64 make the data?

Every 3 bytes become 4 characters, so about a third larger. Korean takes 3 bytes per character in UTF-8, so '한글' (6 bytes) becomes the 8 characters 7ZWc6riA.

What is different about URL-safe Base64?

+ becomes -, / becomes _, and the trailing = padding is dropped. With URL-safe (- _) selected, Hello?> encodes to SGVsbG8_Pg instead of SGVsbG8/Pg==. Pick the same variant when decoding.

Can I convert images or files?

Files up to 1 MB can be turned into a Base64 data URL with the file button. When decoded data is not UTF-8 text (a PDF, a zip, a photo), a button under the error saves those bytes as a file, named after the type it recognises (PDF, ZIP, PNG and so on). Base64 is an encoding anyone can reverse, so do not use it to hide secrets.