Skip to main content
ponderloop

Base64 Encode & Decode

Type or paste text to encode it as Base64, or switch to Decode to turn Base64 back into text. The example “Hello, 世界 👋” is 18 bytes in UTF-8 and becomes 24 characters: SGVsbG8sIOS4lueVjCDwn5GL. Emoji, Hebrew, Chinese and every other script are handled correctly, because text is converted to UTF-8 bytes first. Choose standard or URL-safe Base64, with or without “=” padding, and optional 76-character MIME lines. Decoding ignores spaces and line breaks, accepts missing padding, detects the URL-safe form and points at the first invalid character. You can also turn a file (up to 10.0 MB) into Base64 or a data: URL. Nothing you enter is uploaded.

Updated Runs in your browser: nothing you enter is uploadedHow this tool works

Direction
Stays in your browser

Your text is converted on this device and never uploaded. It is not saved either: reload the page and it is gone.

Encoding options

Result

Encoded 11 characters as 18 UTF-8 bytes.

Input
18 bytes
Base64
24 characters
Size change
+33%

The Base64 alphabet

Each Base64 character stands for 6 bits, a value from 0 to 63. URL-safe Base64 differs only in the last two (62 and 63). The “=” sign is padding, not a value.
ValuesStandard (RFC 4648 §4)URL-safe (RFC 4648 §5)
0–15A B C D E F G H I J K L M N O PA B C D E F G H I J K L M N O P
16–31Q R S T U V W X Y Z a b c d e fQ R S T U V W X Y Z a b c d e f
32–47g h i j k l m n o p q r s t u vg h i j k l m n o p q r s t u v
48–63w x y z 0 1 2 3 4 5 6 7 8 9 + /w x y z 0 1 2 3 4 5 6 7 8 9 - _
padding== (often left out)

Examples

Text, its UTF-8 bytes in hex, and the Base64 this tool produces. Man, Ma and M show how padding fills the last group of four.
TextUTF-8 bytes (hex)Standard Base64URL-safe, no padding
Man4d 61 6eTWFuTWFu
Ma4d 61TWE=TWE
M4dTQ==TQ
Hello48 65 6c 6c 6fSGVsbG8=SGVsbG8
???>>>3f 3f 3f 3e 3e 3ePz8/Pj4+Pz8_Pj4-
café63 61 66 c3 a9Y2Fmw6k=Y2Fmw6k
שלוםd7 a9 d7 9c d7 95 d7 9d16nXnNeV150=16nXnNeV150
世界e4 b8 96 e7 95 8c5LiW55WM5LiW55WM
👋f0 9f 91 8b8J+Riw==8J-Riw

How much bigger Base64 gets

Every 3 bytes become 4 characters, so the encoded form is about 4/3 the size (+33%). Line breaks add a little more.
Input bytesBase64 charactersIncreaseWith 76-character lines
14+300%4
24+100%4
34+33%4
1016+60%16
100136+36%137
1,0001,336+34%1,353
1,000,0001,333,336+33%1,350,879

How to encode or decode Base64

  1. Choose a direction. Pick “Encode text to Base64” to convert text, or “Decode Base64 to text” to read Base64 you have.
  2. Paste your input. Replace the example with your own text or Base64. The result appears as you type.
  3. Pick the Base64 form. For encoding, choose standard or URL-safe, turn “=” padding on or off and add 76-character lines if you need MIME. Decoding detects all of this by itself.
  4. Copy the result. Copy the output, or use “Use result as input” to switch direction and check the round trip.
  5. Convert a file if you need to. Choose a file under 10.0 MB to get its Base64 or a ready-made data: URL. The file is read on your device only.

Frequently asked questions

What is Base64?
Base64 writes any bytes using only 64 safe characters (A–Z, a–z, 0–9, + and /), so binary data can travel through systems built for text, such as email, JSON, HTML, CSS and URLs. It is an encoding, not encryption: anyone can decode it.
Does it work with emoji, Hebrew and Chinese?
Yes. Text is first converted to UTF-8 bytes with the browser’s TextEncoder, and those bytes are encoded. The browser’s plain btoa() function fails on any character above U+00FF, which is why many online tools break on emoji. Decoding reverses the steps with TextDecoder.
What is URL-safe Base64?
It replaces “+” with “-” and “/” with “_”, because the standard characters have special meanings in URLs and file names. It is used in JWTs, many APIs and filenames, and usually leaves out the “=” padding. This tool decodes either form without being told which.
Why does Base64 end with = signs?
Base64 works in groups of 3 bytes that become 4 characters. When the data does not fill the last group, one or two “=” fill it up so the length is a multiple of 4. Many systems accept it without the padding, and this tool does too when decoding.
Why does decoding say my bytes are not valid UTF-8?
Base64 can hold anything: images, PDFs, compressed or encrypted data. When the decoded bytes are not valid UTF-8 text, showing them as characters would only produce garbage, so the tool shows the first bytes in hex instead, and names the file type when it recognises it (PNG, JPEG, GIF, PDF, ZIP, gzip).
What does “invalid character at position” mean?
Base64 uses only letters, digits, “+” and “/” (or “-” and “_”), plus “=” at the end. Spaces and line breaks are ignored, but any other character, such as a quote, a comma or an accented letter, stops decoding. The position counts every character you typed, starting at 1, so you can find it in your text.
How do I Base64 encode a file or an image?
Use the file section: choose a file up to 10.0 MB and copy its Base64, or copy a data: URL such as data:image/png;base64,… to paste into HTML or CSS. The file is read by your browser and never uploaded.
Why is the Base64 text longer than the original?
Each 3 bytes become 4 characters, so the output is about 33% larger (a little more with padding on very short input, and with line breaks). The table above shows exact sizes.
Is my text or file saved or sent anywhere?
No. Encoding and decoding run in your browser, nothing is uploaded, and the text is not saved: reload the page and it is gone. The only thing the site records, if you allow analytics, is that a button was used, never any of your text or files.

How it works

Encoding turns text into UTF-8 bytes with TextEncoder, then takes the bytes three at a time (24 bits) and splits them into four 6-bit values, each looked up in the 64-character alphabet. A last group of one or two bytes yields two or three characters, followed by “=” when padding is on. URL-safe output swaps the characters for values 62 and 63. MIME output breaks the text every 76 characters, using plain line feeds. Decoding first strips an optional data: URL prefix and ignores whitespace, then maps each character back to 6 bits, accepting either alphabet but not both in one text, and treats “=” only as trailing padding (missing padding is fine). A count of characters that leaves a single extra character cannot come from any byte sequence and is reported as incomplete. The bytes are decoded as strict UTF-8 with TextDecoder; if that fails, a hex preview is shown instead of replacement characters. Files are read with FileReader into memory, encoded the same way and kept only on the page.

Sources

All toolsHome & DIY calculators