Hongmu Notes

🅱️ Base64 encoding and decoding

Paste the text and click "Encode" to get the Base64 string, or paste the Base64 string and click "Decode" to restore the original text; supports Chinese and long text, and the entire process is completed locally in the browser.

Base64 encoding and decoding tools


Instructions for use

Put the original text or a ready-made Base64 string in the input box, click "BASE64 Encoding" to turn it into Base64, and click "BASE64 Decoding" to restore Base64 to the original text. The result will directly replace the content of the input box, so please copy and save the result of the previous step before changing the content. "Result generated" or the reason for failure will be given below the button and in the status line to help determine whether the conversion is successful.

✅ How to check the results

  • The encoding result only contains uppercase and lowercase letters, numbers and plus slashes, and there may be an equal sign at the end.
  • Decode the encoding result again to restore the original text, indicating that the process is correct.
  • When decoding does not produce a result, remove the spaces and newlines in the string and try again.

🔒 Data and privacy

Encoding and decoding are completed locally in the browser, and the input content does not go through the server and is cleared when the page is refreshed. Please remember that Base64 only encodes and does not encrypt. The result can be restored by anyone. Do not use it to protect passwords and keys.

Base64 length conversion

How long will it be after encoding? Calculate it first before starting.

Conversion rules

Every three bytes are encoded into four characters, a ratio of approximately four to three.

The resulting length is padded up to a multiple of four.

The impact of the equal sign

When the number of bytes is divided by three, two equal signs are added when the remainder is one, and one is added when the remainder is two.

The equal sign is not added during integer division.

Chinese situation

A Chinese character usually occupies three bytes and is approximately four characters after encoding.

English and numbers usually occupy one byte per character.

Estimated use

Determine in advance whether the target field can accommodate the results.

Plan the amount of content per batch when processing in batches.

quick check

After the encoding is completed, you can directly count the number of characters in the result and compare it with the estimate.

When the gap is large, first check whether the original text contains unnecessary line breaks.

All keywords and tutorials 12

❓ FAQ

Why is the result longer than the original text?
Base64 uses four characters to represent three bytes, and the length will naturally increase by about 30%.
How to estimate in Chinese?
A Chinese character usually occupies three bytes, which is approximately equal to four characters after encoding.