Skip to content

Base64 Encode and Decode Text Online

Turn text into Base64 or a Base64 string back into readable text. A URL-safe switch produces the base64url form used in JWTs and query strings.

Runs in your browserFree, no sign-upLast reviewed

Settings

Results update automatically as you type.

Base64

SGVsbG8sIHdvcmxkIQ==

Size

Input
13 chars
Output
20 chars
Overhead
54%

Quick answers

What is Hello in Base64?
Hello encodes to SGVsbG8= in Base64. The lowercase phrase hello world becomes aGVsbG8gd29ybGQ=, and Hello, world! with the comma and exclamation mark becomes SGVsbG8sIHdvcmxkIQ==. Base64 is case-sensitive, so changing one capital letter changes the output.
How do I decode a Base64 string to text?
Paste the string, set Action to Decode from Base64 and read the Decoded text panel. Spaces and line breaks inside the string are ignored, and missing = padding is tolerated. SGVsbG8sIHdvcmxkIQ== decodes to Hello, world!
Is Base64 encryption?
No. Base64 has no key and no secret. It is a fixed, public mapping from bytes to 64 printable characters, so anyone can decode it in a second. Use it to move data through text-only channels, never to hide a password or token.
What is the difference between Base64 and base64url?
They differ in two characters and the padding. Standard Base64 uses + and / and pads with =. base64url uses - and _ instead and usually drops the = signs, so the value can sit in a URL or filename without escaping. The text >>>??? is Pj4+Pz8/ in standard form and Pj4-Pz8_ in URL-safe form.
Why does a Base64 string end with = or ==?
The = sign is padding. Base64 turns every 3 bytes into 4 characters, and when the input is not a multiple of 3 bytes the last group is filled out with one or two = signs. One leftover byte gives ==, two leftover bytes give a single =.
How much bigger is Base64 than the original?
About 33% bigger, plus padding. Every 3 bytes become 4 characters, so the output length is 4 times the byte count divided by 3, rounded up to a multiple of 4. A 3-byte input gives 4 characters; a 13-byte input gives 20.

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.

TextBase64Input lengthOutput length
HelloSGVsbG8=58
hello worldaGVsbG8gd29ybGQ=1116
Hello, world!SGVsbG8sIHdvcmxkIQ==1320
testdGVzdA==48
truedHJ1ZQ==48
passwordcGFzc3dvcmQ=812
1234567890MTIzNDU2Nzg5MA==1016
user:passworddXNlcjpwYXNzd29yZA==1320
admin:secretYWRtaW46c2VjcmV01216
{"alg":"HS256","typ":"JWT"}eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ92736
The quick brown fox jumps over the lazy dogVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==4360

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.

InputBytesStandard Base64URL-safe outputPadding
a1YQ==YQTwo = signs
ab2YWI=YWIOne = sign
abc3YWJjYWJjNone
abcd4YWJjZA==YWJjZATwo = signs
Hello5SGVsbG8=SGVsbG8One = sign
Base646QmFzZTY0QmFzZTY0None

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.

TextStandardURL-safe (- and _)
>>>???Pj4+Pz8/Pj4-Pz8_
Hello?>SGVsbG8/Pg==SGVsbG8_Pg
subjects?_d=1c3ViamVjdHM/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. 1

    Paste plain text or a Base64 string into the Text or Base64 box.

  2. 2

    Set Action to Encode to Base64 or Decode from Base64.

  3. 3

    When encoding a value for a URL, cookie, filename or JWT, tick URL-safe output (- and _).

  4. 4

    Read the Base64 output and the Size panel, which lists Input, Output and Overhead.

  5. 5

    Copy the result, or download an encoded value as encoded.txt.

Frequently asked questions

Can I decode a whole JWT here?
Not in one go. A JWT is three base64url segments joined by dots, and the dot is not a Base64 character, so the full token is rejected. Paste the header or the payload on its own. The third segment is a signature made of raw bytes and does not decode to readable text.
Why did my decoded text come out as question-mark boxes?
The Base64 was valid but the bytes inside are not UTF-8 text. That happens when the original was a file, compressed data, an encrypted value or text saved in a different encoding such as UTF-16. The tool can only display decoded bytes as UTF-8.
Does a space or line break change the Base64 output?
Yes when encoding. Every character in the box is encoded, including trailing spaces and line breaks, so a stray newline changes the last few characters of the result. When decoding, the opposite is true: all whitespace is removed before the string is read.
How do I build an HTTP Basic Authorization header?
Join the username and password with a colon, encode that with URL-safe output off, and put the result after the word Basic and a space. For user:password the header is Authorization: Basic dXNlcjpwYXNzd29yZA==. Send it only over HTTPS, because the value is trivially reversible.
Why does the Overhead figure show more than 33%?
The 33% figure is the long-run average. Short inputs are dominated by padding: one character becomes four, which is 300%. The panel also compares character counts, so text with accents, non-Latin scripts or emoji shows a higher figure because each of those characters is two to four bytes.
Is the same text always encoded to the same Base64?
Yes, as long as the bytes are the same. Base64 is deterministic and has no random element. Differences between tools nearly always come from the text encoding used before Base64 (UTF-8 here), a trailing newline, or the standard versus URL-safe alphabet.
Is my text sent to a server?
No. Encoding and decoding run in your browser with JavaScript, and nothing you paste is uploaded. That said, treat any Base64 value as readable by anyone who sees it.

Looking for something else? Browse all text tools or see every tool.