Base64 Converter
Encode text to Base64 or decode Base64 to text. UTF-8, standard and URL-safe alphabets, optional padding on decode, up to 250,000 characters. How it works
Use the Base64 Converter
About the Base64 Converter
Hello in Base64 is SGVsbG8=. The converter turns text into UTF-8 bytes, writes every 3 bytes as 4 characters and pads the end with = when the last group is short. Decoding reverses it and accepts both the standard and the URL-safe alphabet. It handles text only, so use Base64 File to String for a file.
Text, its UTF-8 size and its Base64 form
| Text | UTF-8 bytes | Standard Base64 | URL-safe Base64 |
|---|---|---|---|
| a | 1 | YQ== | YQ |
| ab | 2 | YWI= | YWI |
| abc | 3 | YWJj | YWJj |
| Hello | 5 | SGVsbG8= | SGVsbG8 |
| Hello, World! | 13 | SGVsbG8sIFdvcmxkIQ== | SGVsbG8sIFdvcmxkIQ |
| user:pass | 9 | dXNlcjpwYXNz | dXNlcjpwYXNz |
| é | 2 | w6k= | w6k |
| 日本 | 6 | 5pel5pys | 5pel5pys |
| hello?>> | 8 | aGVsbG8/Pj4= | aGVsbG8_Pj4 |
Each row is what the converter returns, with and without the URL-safe option. The URL-safe form swaps + and / for - and _ and drops the = padding (RFC 4648, section 5). A multiple of 3 bytes needs no padding.
How to use this tool
- Choose Encode to turn text into Base64, or Decode to turn Base64 into text.
- Type or paste the input. The result appears as you type.
- In Encode mode, switch on URL-safe output for - and _ with no padding.
- Press Copy to copy the result.
Frequently asked questions
- How do I decode a Base64 string to text?
- Choose Decode and paste the string. SGVsbG8= and SGVsbG8 both decode to Hello, because padding is optional, and spaces or line breaks in the pasted text are ignored. A string in the URL-safe alphabet decodes too: aGVsbG8_Pj4 gives hello?>>.
- Why does decoding say the Base64 is binary data, not UTF-8 text?
- The string is valid Base64, but the bytes it holds are not UTF-8 text. /w== is the single byte 0xFF, which UTF-8 never uses, so the page reports binary data instead of an invalid string. Use Base64 File to String to decode it to a file.
- What is URL-safe Base64?
- It is the same encoding with - and _ in place of + and /, usually without the = padding, so the text can sit in a URL or a file name (RFC 4648, section 5). hello?>> is aGVsbG8/Pj4= in the standard form and aGVsbG8_Pj4 in the URL-safe form. A string that mixes + or / with - or _ is rejected as invalid.
- Why does Base64 end with = or ==?
- Base64 reads 3 bytes at a time and writes 4 characters. When the input is 1 byte over a multiple of 3, two = pad the end (a gives YQ==), and when it is 2 bytes over, one = does (ab gives YWI=). A multiple of 3 bytes, such as abc giving YWJj, needs none.
- Is Base64 encryption?
- No. It is a reversible encoding that anyone can decode, as dXNlcjpwYXNz decoding to user:pass shows. Do not use it to hide a password or a key.
- Is there a size limit, and is my text uploaded?
- Input is limited to 250,000 characters, and a longer paste shows a message instead of a result. The conversion runs in your browser and the text is not uploaded.
Related Tools
View all toolsJSON Formatter
Paste JSON to format it with 2 spaces, 4 spaces or tabs, minify it or sort its keys. A syntax error is reported with its line, column and a caret under it.
JSON Path Query Tool
Test a JSONPath expression on your JSON and see the match count, each matching value and its path. Filters such as ?(@.price < 10) work. Up to 100 KB.
URL Encoder/Decoder
Percent-encode or decode text as you type: one value with encodeURIComponent or a whole URL with encodeURI, and an option to read + as a space.
UUID Generator
Generate 1 to 1,000 random v4 UUIDs, or time-based v1, or name-based v5 and v3 from a namespace and a name, and copy them. Repeats of v4 are very unlikely.
ULID Generator
Generate 1 to 500 ULIDs, 26-character IDs that sort by creation time, in upper or lower case, and decode any ULID to the date it was made.
HTML Entity Encoder
Encode text to HTML entities (& < > " ') or decode any of the 2,231 named references in the HTML standard and numeric ones such as é.