Why use Base64 Encoder & Decoder
Paste text and this tool returns its Base64 form; switch the Action and it turns a Base64 string back into text. Text is converted to UTF-8 bytes first, so accents, Chinese characters and emoji all round-trip correctly. "Hello, world!" encodes to SGVsbG8sIHdvcmxkIQ== and decodes back to the same 13 characters. Ticking the URL-safe option swaps + for - and / for _ and removes the trailing = signs, which is the base64url variant defined in RFC 4648. The decoder accepts both variants, with or without padding, and ignores spaces and line breaks. Base64 is an encoding, not encryption: anyone can reverse it.
Common text values in Base64
Each row was produced by this encoder with URL-safe output switched off. Text is read as UTF-8.
| Text | Base64 | Input length | Output length |
|---|---|---|---|
| Hello | SGVsbG8= | 5 | 8 |
| hello world | aGVsbG8gd29ybGQ= | 11 | 16 |
| Hello, world! | SGVsbG8sIHdvcmxkIQ== | 13 | 20 |
| test | dGVzdA== | 4 | 8 |
| true | dHJ1ZQ== | 4 | 8 |
| password | cGFzc3dvcmQ= | 8 | 12 |
| 1234567890 | MTIzNDU2Nzg5MA== | 10 | 16 |
| user:password | dXNlcjpwYXNzd29yZA== | 13 | 20 |
| admin:secret | YWRtaW46c2VjcmV0 | 12 | 16 |
| {"alg":"HS256","typ":"JWT"} | eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9 | 27 | 36 |
| The quick brown fox jumps over the lazy dog | VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw== | 43 | 60 |
The user:password row is the value that follows the word Basic in an HTTP Basic Authorization header. The JSON row is why so many JWTs start with eyJ.
How Base64 encoding works, step by step
3 bytes (24 bits) -> 4 groups of 6 bits -> 4 characters from A-Z a-z 0-9 + /
Take the word Man. Its bytes are 77, 97 and 110, or 01001101 01100001 01101110 in binary. Join those 24 bits and cut them into four 6-bit groups: 010011, 010110, 000101, 101110. Those are the numbers 19, 22, 5 and 46. In the Base64 alphabet, 0 to 25 are A to Z, 26 to 51 are a to z, 52 to 61 are the digits 0 to 9, 62 is + and 63 is /. Looking up 19, 22, 5 and 46 gives T, W, F and u, so Man becomes TWFu. Decoding runs the same table backwards: four characters give 24 bits, which split into three bytes.
Base64 padding chart: when you get =, == or none
Padding depends only on the number of bytes left over after dividing by 3.
| Input | Bytes | Standard Base64 | URL-safe output | Padding |
|---|---|---|---|---|
| a | 1 | YQ== | YQ | Two = signs |
| ab | 2 | YWI= | YWI | One = sign |
| abc | 3 | YWJj | YWJj | None |
| abcd | 4 | YWJjZA== | YWJjZA | Two = signs |
| Hello | 5 | SGVsbG8= | SGVsbG8 | One = sign |
| Base64 | 6 | QmFzZTY0 | QmFzZTY0 | None |
A padded Base64 string is always a multiple of 4 characters long and never ends in three = signs. An unpadded string whose length leaves a remainder of 1 when divided by 4 has been cut short and cannot be decoded.
Standard Base64 vs URL-safe Base64 output
The two variants only differ when the encoded value happens to contain index 62 or 63, or needs padding.
| Text | Standard | URL-safe (- and _) |
|---|---|---|
| >>>??? | Pj4+Pz8/ | Pj4-Pz8_ |
| Hello?> | SGVsbG8/Pg== | SGVsbG8_Pg |
| subjects?_d=1 | c3ViamVjdHM/X2Q9MQ== | c3ViamVjdHM_X2Q9MQ |
| Hello, world! | SGVsbG8sIHdvcmxkIQ== | SGVsbG8sIHdvcmxkIQ |
| 😀 | 8J+YgA== | 8J-YgA |
In a URL, + is read as a space by form decoding, / is a path separator and = separates keys from values. That is why tokens, JWT segments and filenames use the URL-safe alphabet.
Decoding examples, including a JWT segment
Decode a JWT header
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9 with Action set to Decode from Base64
{"alg":"HS256","typ":"JWT"}
Decode one segment at a time. Pasting a whole token with its two dots returns the message "That does not look like valid Base64 text."
Decode a JWT payload with no padding
eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ
{"sub":"1234567890","name":"John Doe","iat":1516239022}
The payload is only encoded, not encrypted, so never put secrets in one.
Decode a Basic auth value
dXNlcjpwYXNzd29yZA==
user:password
Decode a string wrapped across lines
SGVs on one line and bG8= on the next
Hello
Whitespace is stripped before decoding, so MIME-style line wrapping is not a problem.
Decode accented text
Y2Fmw6k=
café
What this Base64 tool does not do
- It works on text only. There is no file upload, so it cannot encode an image or PDF; use the image to Base64 tool for pictures.
- Decoded bytes are shown as UTF-8 text. Base64 that holds binary data, such as an image or a gzip stream, decodes to unreadable replacement characters.
- The Size panel counts characters, not bytes. For plain ASCII the two are equal, but café shows 4 chars in and 8 out (100% overhead) because é is two bytes in UTF-8, and a single emoji such as 😀 is reported as 2 chars.
- It does not wrap output at 76 characters or encode each line separately. The whole box is treated as one value, line breaks included.
- URL-safe output only applies when encoding. When decoding, both alphabets are accepted automatically.
How to get your result
- 1
Paste plain text or a Base64 string into the Text or Base64 box.
- 2
Set Action to Encode to Base64 or Decode from Base64.
- 3
When encoding a value for a URL, cookie, filename or JWT, tick URL-safe output (- and _).
- 4
Read the Base64 output and the Size panel, which lists Input, Output and Overhead.
- 5
Copy the result, or download an encoded value as encoded.txt.