FreeToolsHub

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 / FeatureBase64 EncodingHexadecimal (Base16)URL Encoding (Percent)
Alphabet Size64 characters16 characters (0-9, A-F)Varies (Escapes non-alphanumeric)
Size Overhead~33% increase100% increase (double size)Up to 200% for special characters
Padding Symbol= (equals sign)NoneNone (uses %)
Binary SupportFullFullLimited (primarily for URLs)
ReadabilityObfuscated stringRaw hex pairsPercent-encoded blocks

Edge Cases, Limitations, and Binary Constraints

When implementing Base64 in applications, keep these constraints in mind:

  1. 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.
  2. Unicode and Multi-byte Characters: Standard Base64 functions in legacy web browsers (such as btoa and atob) only support 8-bit ASCII characters. Attempting to encode multi-byte characters like emojis or non-Latin text (e.g., こんにちは or 😊) directly throws a DOMException error. The input must first be serialized into UTF-8 binary bytes before encoding.
  3. 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.
  4. 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

100% Client-Side Privacy

Encodings process locally in your browser—sensitive API tokens and credentials are never transmitted.

Supports Binary & UTF-8 Strings

Handles special characters, UTF-8 strings, and URL-safe Base64 conversions cleanly.

Fast Developer Workflow

Encode and decode authentication headers and web tokens in milliseconds.

Free & Unlimited Usage

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. 1

    Input Data: Paste your plain text string or Base64 encoded payload into the input editor.

  2. 2

    Select Action: Click "Encode to Base64" or "Decode from Base64".

  3. 3

    Copy Result: Copy the converted output string to your clipboard instantly.

Practical Examples

Input Example

Text: ABC, Action: Encode

Expected Output
Base64: QUJD

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.

Explore category: Text & Editing
Ready to boost your productivity?

Browse our full list of free text & editing and make your daily content, coding, or math tasks easier.

Related Text & Editing

View all