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
Your text is converted on this device and never uploaded. It is not saved either: reload the page and it is gone.
Result
Encoded 11 characters as 18 UTF-8 bytes.
- Input
- 18 bytes
- Base64
- 24 characters
- Size change
- +33%
File to Base64 or data URL
Choose a file up to 10.0 MB. It is read by your browser and never uploaded. The encoding options above apply.
The Base64 alphabet
| Values | Standard (RFC 4648 §4) | URL-safe (RFC 4648 §5) |
|---|---|---|
| 0–15 | A B C D E F G H I J K L M N O P | A B C D E F G H I J K L M N O P |
| 16–31 | Q R S T U V W X Y Z a b c d e f | Q R S T U V W X Y Z a b c d e f |
| 32–47 | g h i j k l m n o p q r s t u v | g h i j k l m n o p q r s t u v |
| 48–63 | w 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 | UTF-8 bytes (hex) | Standard Base64 | URL-safe, no padding |
|---|---|---|---|
| Man | 4d 61 6e | TWFu | TWFu |
| Ma | 4d 61 | TWE= | TWE |
| M | 4d | TQ== | TQ |
| Hello | 48 65 6c 6c 6f | SGVsbG8= | SGVsbG8 |
| ???>>> | 3f 3f 3f 3e 3e 3e | Pz8/Pj4+ | Pz8_Pj4- |
| café | 63 61 66 c3 a9 | Y2Fmw6k= | Y2Fmw6k |
| שלום | d7 a9 d7 9c d7 95 d7 9d | 16nXnNeV150= | 16nXnNeV150 |
| 世界 | e4 b8 96 e7 95 8c | 5LiW55WM | 5LiW55WM |
| 👋 | f0 9f 91 8b | 8J+Riw== | 8J-Riw |
How much bigger Base64 gets
| Input bytes | Base64 characters | Increase | With 76-character lines |
|---|---|---|---|
| 1 | 4 | +300% | 4 |
| 2 | 4 | +100% | 4 |
| 3 | 4 | +33% | 4 |
| 10 | 16 | +60% | 16 |
| 100 | 136 | +36% | 137 |
| 1,000 | 1,336 | +34% | 1,353 |
| 1,000,000 | 1,333,336 | +33% | 1,350,879 |
How to encode or decode Base64
- Choose a direction. Pick “Encode text to Base64” to convert text, or “Decode Base64 to text” to read Base64 you have.
- Paste your input. Replace the example with your own text or Base64. The result appears as you type.
- 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.
- Copy the result. Copy the output, or use “Use result as input” to switch direction and check the round trip.
- 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
More free tools
- JSON Formatter & ValidatorValidate JSON with the exact line and column of any error, then pretty-print, minify or sort keys. Big numbers keep every digit. Runs in your browser.
- URL Encode & DecodePercent-encode or decode URLs and query strings with correct UTF-8, split a URL into parts and parameters, and catch double-encoding. Runs in your browser.
- HTML Entity Encoder & DecoderEscape text for safe HTML or decode named, decimal and hex character references the way browsers do, with all 2,231 standard names. Runs in your browser.
- JWT DecoderDecode a JWT to its header and payload, read exp, iat and nbf as UTC times, spot expired or alg none tokens, and check HMAC signatures. Runs locally.
- Hash GeneratorHash text or a file with SHA-256, SHA-1, SHA-384, SHA-512, MD5 and CRC32, add an HMAC key, and check a checksum. Runs in your browser; nothing is uploaded.
- Text to Binary ConverterConvert text to binary, hex, octal or decimal bytes and back. UTF-8 by default (é is 2 bytes, an emoji 4) or UTF-16, with a per-character breakdown.