Free Base64 Encoder & Decoder Online
Convert text data to Base64 encoding or decode Base64 strings back to text instantly.
Understanding Base64 Encoding and Decoding
Base64 is a binary-to-text encoding scheme designed to represent binary data in an ASCII string format. In network communication, many transmission protocols (such as SMTP for email or HTTP form transfers) were originally designed to handle only standard 7-bit ASCII text characters. When transmitting binary files (like images, PDF files, or audio clips) over these channels, raw binary bytes can be misinterpreted as control characters by older routing equipment, corrupting the file. Base64 resolves this by translating any binary sequence into a safe set of 64 printable characters.
Today, Base64 is widely used to embed small images directly inside HTML or CSS files (using Data URIs), send API keys in Authorization headers, and transmit encrypted payloads. However, it is crucial to remember that Base64 is an encoding scheme, not a security encryption method. Anyone can decode a Base64 string back to its original format in milliseconds using this tool.
How it Works: The Radix-64 Translation Algorithm
The Base64 algorithm maps binary inputs into a character index set containing 64 symbols: uppercase English letters (A-Z), lowercase letters (a-z), numbers (0-9), the plus sign (+), and the slash (/). The encoding process follows these mathematical steps:
1. Splitting into 24-bit Blocks
The input data is read as a stream of 8-bit bytes. The algorithm groups the bytes into blocks of 3 bytes (a total of 24 bits):
$$\text{Block Size} = 3 \text{ bytes} \times 8 \text{ bits} = 24 \text{ bits}$$
2. Slicing into 6-bit Segments
The 24-bit block is divided into four 6-bit segments. Each 6-bit segment represents a decimal value between 0 and 63 ($2^6 = 64$):
$$\text{Segment Index} = \text{Value} \in [0, 63]$$
3. Mapping to the Base64 Alphabet
Each 6-bit value is mapped to its matching character in the Base64 index table (e.g., index 0 is A, index 26 is a, index 62 is +, index 63 is /).
4. Padding Calculations
If the input length is not a multiple of 3 bytes, padding is added at the end using the equals sign (=):
- 1 Remaining Byte (8 bits): Padded with 4 zero bits to form a 12-bit block, yielding 2 Base64 characters and 2 padding characters (
==). - 2 Remaining Bytes (16 bits): Padded with 2 zero bits to form an 18-bit block, yielding 3 Base64 characters and 1 padding character (
=).
Worked Examples: 3 Conversion Scenarios
Example 1: Standard No-Padding Case ("ABC")
- Input Text:
ABC(3 bytes) - Binary Values:
A=01000001,B=01000010,C=01000011- Combined 24 bits:
010000010100001001000011 - 6-bit Divisions:
- Segment 1:
010000(decimal 16) $\rightarrow$ Base64 character:Q - Segment 2:
010100(decimal 20) $\rightarrow$ Base64 character:U - Segment 3:
001001(decimal 9) $\rightarrow$ Base64 character:J - Segment 4:
000011(decimal 3) $\rightarrow$ Base64 character:D - Output:
QUJD
Example 2: One Padding Character Case ("AB")
- Input Text:
AB(2 bytes - 16 bits:0100000101000010) - Process: Add 2 zero bits at the end to make it 18 bits:
010000010100001000. - 6-bit Divisions:
- Segment 1:
010000(16) $\rightarrow$Q - Segment 2:
010100(20) $\rightarrow$U - Segment 3:
100000(32) $\rightarrow$I - Padding: Append one
= - Output:
QUI=
Example 3: Two Padding Characters Case ("A")
- Input Text:
A(1 byte - 8 bits:01000001) - Process: Add 4 zero bits to make it 12 bits:
010000010000. - 6-bit Divisions:
- Segment 1:
010000(16) $\rightarrow$Q - Segment 2:
010000(16) $\rightarrow$Q - Padding: Append two
= - Output:
QQ==
Comparison: Base64 vs. Hexadecimal vs. URL Encoding
| Attribute / Feature | Base64 Encoding | Hexadecimal (Base16) | URL Encoding (Percent) |
|---|---|---|---|
| Alphabet Size | 64 characters | 16 characters (0-9, A-F) | Varies (Escapes non-alphanumeric) |
| Size Overhead | ~33% increase | 100% increase (double size) | Up to 200% for special characters |
| Padding Symbol | = (equals sign) | None | None (uses %) |
| Binary Support | Full | Full | Limited (primarily for URLs) |
| Readability | Obfuscated string | Raw hex pairs | Percent-encoded blocks |
Edge Cases, Limitations, and Binary Constraints
When implementing Base64 in applications, keep these constraints in mind:
- Data Size Inflation: Because every 3 bytes of raw data are represented as 4 characters, Base64 increases the file size by exactly 33.3%. For high-bandwidth transfers or large databases, storing data as Base64 rather than raw binary causes unnecessary storage and network overhead.
- Unicode and Multi-byte Characters: Standard Base64 functions in legacy web browsers (such as
btoaandatob) only support 8-bit ASCII characters. Attempting to encode multi-byte characters like emojis or non-Latin text (e.g.,こんにちはor😊) directly throws aDOMExceptionerror. The input must first be serialized into UTF-8 binary bytes before encoding. - Safe URL Transmissions: Standard Base64 uses the characters
+and/, which have specific administrative meanings in URL paths. For transmitting data in query parameters, use Base64Url encoding, which replaces+with-and/with_, and strips the trailing padding characters. - Security Misconceptions: Base64 is an encoding utility, not a cryptographic hash or encryption algorithm. It provides zero security. Anyone can decode the value instantly without a key.
Key Benefits & Features
Encodings process locally in your browser—sensitive API tokens and credentials are never transmitted.
Handles special characters, UTF-8 strings, and URL-safe Base64 conversions cleanly.
Encode and decode authentication headers and web tokens in milliseconds.
Convert data instantly on desktop or mobile with zero signups.
How to Use the Base64 Encoder/Decoder Step-by-Step
This utility runs entirely inside your browser using client-side JavaScript. We prioritize your security: none of your inputted text is logged or stored.
- 1
Input Data: Paste your plain text string or Base64 encoded payload into the input editor.
- 2
Select Action: Click "Encode to Base64" or "Decode from Base64".
- 3
Copy Result: Copy the converted output string to your clipboard instantly.
Practical Examples
Text: ABC, Action: Encode
Frequently Asked Questions (FAQ)
What is Base64 encoding used for?▼
Base64 encoding converts binary data into ASCII text strings to transmit data safely across HTTP networks without data corruption.
Is Base64 considered encryption?▼
No. Base64 is an encoding format for data transport, not encryption. Anyone can decode a Base64 string back to original text.
Are my encoded tokens or strings saved on a server?▼
No. Conversion runs strictly client-side in your browser using JavaScript APIs for absolute security.
Is Base64 encoding free to use?▼
Yes, FreeToolsHub provides 100% free Base64 encoding and decoding with no usage restrictions.
Browse our full list of free text & editing and make your daily content, coding, or math tasks easier.
Related Tools & Utilities
Related Text & Editing
View allSafe-encode special characters in URLs or decode encoded URL queries.
Encode characters to secure HTML entities or decode safe entities.
Convert local image files into Base64 data strings for code inline inclusion.
Render Base64 data:image strings into preview images and download them.