The Base64 Encoder lets you safely convert plain text or binary content into a Base64 string. This encoding method is ideal when you need to transfer binary data over text-based formats like JSON, HTML, or email. You can also explore our Base64 Decoder for decoding, or UTF8 Encoder if you’re working with multilingual characters.
Test your APIs today!
Write in plain English — Qodex turns it into secure, ready-to-run tests.
Regular Expression - Documentation
What is Base64 Encoding?
Base64 is a binary-to-text encoding scheme that turns binary data into an ASCII string format using a set of 64 characters. These include:
Padding with = is used if the data doesn’t fill up the required 24-bit chunks. It’s not encryption — just a safe way to encode data for text-based transmission.
How Base64 Encoding Works
Binary Conversion: The input text or file is first converted into its binary representation.
Chunking: Binary data is divided into 6-bit segments.
Mapping: Each 6-bit segment is mapped to a character in the Base64 index table.
Padding: If the last chunk is less than 24 bits, = padding is added to make it valid.
How to Encode Using Base64 in Practice
Example 1: Encoding a Text String
Input:
Binary Representation:
Base64 Output:
Example 2: Encoding a JSON Payload
JSON Input:
Base64 Output:
Example 3: Encoding an Image (binary)
A .png file encoded in Base64 can be used in HTML as:
Use Cases
Embedding images in HTML/CSS via data: URIs
Sending files or payloads in APIs where binary is not allowed
Storing small files in databases or text-based formats
Email attachments encoded as MIME Base64
Pro Tips
Shorten Payloads: Base64 increases size by ~33%. Avoid overusing for large files.
Use UTF-8 before encoding multilingual content. Try our UTF8 Encoder to prepare data.
Combine with Decoder: Pair with our Base64 Decoder for round-trip conversions.
Escape Safely: For use in URLs, use a URL Encoder afterward to escape +, /, and =.