What is base64 encoding?
Some tools do not accept a full set of characters. There are also text file formats that do not have a way to escape easily all special characters. Some special characters are new lines, tabs, characters that are otherwise used for other purposes - &, % etc.
Example usages:
- content of cookies
- some url parameters - but often url encoding is used there
- contents of some kubernetes objects
- encoding binary content to store as text
Example of base64 encoded text
Encoding whole text
Text to encode
“A World of Dew” by Kobayashi Issa
A world of dew,
And within every dewdrop
A world of struggle. Base64 encoded text
4oCcQSBXb3JsZCBvZiBEZXfigJ0gYnkgS29iYXlhc2hpIElzc2EKCkEgd29ybGQgb2YgZGV3LAoKQW5kIHdpdGhpbiBldmVyeSBkZXdkcm9wCgpBIHdvcmxkIG9mIHN0cnVnZ2xlLiA=How Base64 Encoding Works
Base64 encoding converts binary data into a text format by representing it using 64 different ASCII characters. The process works as follows:
- The input text is converted to binary data (using UTF-8 encoding)
- The binary data is split into groups of 6 bits (since 2^6 = 64)
- Each 6-bit group is converted to a corresponding character from the Base64 alphabet
- If the input length is not divisible by 3, padding characters ('=') are added to the output
Parameters
- Input text: Any text you want to encode to Base64 format
Common Use Cases
- Embedding binary data in JSON, XML, or HTML
- Storing data in cookies or URL parameters
- Email attachments (MIME encoding)
- Storing configuration data in text files
- Encoding data for APIs that don't support binary data
Tip:
Base64 encoding increases the size of your data by approximately 33% compared to the original binary data. This is because every 3 bytes of input data are represented as 4 bytes in Base64 format.
Related Tools
- Decode Base64 - Convert Base64 encoded text back to its original form
- URL Encode - Encode text for use in URLs
- Hex Encode - Convert text to hexadecimal representation
- SHA-256 Hash - Generate SHA-256 hash of text
- MD5 Hash - Generate MD5 hash of text
All Tools
See all available tools