Base64 Encoder

Encode and decode data using Base64 encoding

Tool Overview

The Base64 Encoder allows you to encode text or binary data into Base64 format and decode Base64 strings back to their original form. Base64 is commonly used for embedding binary data in text-based formats like JSON, XML, and URLs.

Go to Tool

How It Works

Base64 encoding is a binary-to-text encoding scheme that converts binary data into ASCII string format for safe transmission.

Encoding Process

  1. UTF-8 Conversion: Input text is converted to UTF-8 byte sequence.
  2. 6-bit Grouping: Bytes are grouped into 6-bit chunks (2^6 = 64 possible values).
  3. Character Mapping: Each 6-bit group is mapped to a Base64 character.
  4. Padding: If the last group has fewer than 6 bits, it is padded with "=".

Character Set

A-Z (26 characters) a-z (26 characters) 0-9 (10 characters) + / (2 special characters) = (padding character)

Decoding Process

  1. Validation: Checks for valid Base64 characters and padding.
  2. Character Conversion: Each Base64 character is converted back to its 6-bit value.
  3. Byte Reconstruction: 6-bit values are combined to reconstruct the original byte sequence.
  4. UTF-8 Decoding: Bytes are decoded back to text using UTF-8.

URL-Safe Mode

Standard Base64: + / URL-Safe Base64: - _ Example: Standard: dGVzdA== URL-Safe: dGVzdA== (unchanged if no + or /)

URL-safe mode replaces "+" with "-" and "/" with "_", making the encoded string safe for URL parameters and filenames. The tool uses JavaScript's TextEncoder/TextDecoder APIs to handle UTF-8 encoding properly, supporting all Unicode characters including emojis and special symbols.

Features

  • Text encoding to Base64
  • Base64 decoding to text
  • UTF-8 character support
  • URL-safe Base64 option
  • Copy result to clipboard

Usage Examples

Example 1: Basic Encoding

Input: Hello World

Output: SGVsbG8gV29ybGQ=

Example 2: UTF-8 Encoding

Input: 你好世界

Output: 5L2g5aW95LiW55WM

Example 3: URL-Safe Encoding

Input: data:image/png;base64,iVBORw0...

Output: data:image/png;base64,iVBORw0...

FAQ

What is Base64 encoding?

Base64 is a binary-to-text encoding scheme that converts binary data into ASCII string format. It's commonly used for transmitting data over channels that only support text.

When should I use Base64?

Base64 is useful when you need to embed binary data (like images) in text formats, store binary data in databases that only support text, or transmit data through text-based APIs.

Does Base64 encoding compress data?

No, Base64 encoding increases the data size by approximately 33% because it converts 3 bytes of binary data into 4 ASCII characters.