Skip to main content

Text to Base64

Encode text to Base64 and decode Base64 back to text instantly

Text to Base64 encoder and decoder. Convert text to Base64 encoding and decode Base64 strings back to readable text. Handles Unicode, emojis, and binary data


How to encode text to Base64?

Base64 encoding converts arbitrary text into a safe ASCII representation that can be transmitted across systems designed for text-only data. This tool handles both encoding and decoding:

  • Enter or paste your text into the input area. This can be any text content: simple strings like 'Hello World', JSON data like '{"key":"value"}', image data URIs, XML documents, configuration values, or even binary data represented as text. The tool accepts UTF-8 encoded text and encodes it according to the Base64 alphabet specification (RFC 4648).
  • Choose your operation: 'Encode' converts your text into Base64 format, producing a string containing only A-Z, a-z, 0-9, +, /, and = (padding characters). 'Decode' converts a Base64-encoded string back to its original text form. Both operations happen instantly with a single click.
  • Review the result in the output area. Encoded output shows the Base64 string, which typically expands the original text by approximately 33% (every 3 bytes of input become 4 Base64 characters). Decoded output shows the original readable text restored from the Base64 encoding. If the input Base64 string is malformed, the tool displays a clear error message indicating the issue.
  • Copy the result using the Copy button. Encoded strings can be embedded in data URIs (data:text/plain;base64,...), included in JSON payloads, passed as URL parameters (with + replaced by - and / replaced by _ for URL-safe Base64), or stored in configuration files that require ASCII-only content.

Related Tools

You May Also Need

Understanding how Base64 encoding works under the hood

Base64 encoding operates on a simple mathematical principle: it converts every 3 bytes (24 bits) of input data into 4 characters from a 64-character alphabet. Each Base64 character represents exactly 6 bits of data (since 2^6 = 64). The encoding process takes 3 input bytes, splits them into four 6-bit groups, and maps each group to a character in the Base64 table: A-Z (values 0-25), a-z (values 26-51), 0-9 (values 52-61), + (value 62), and / (value 63). When the input length isn't divisible by 3, padding characters (=) are added to ensure the output length is a multiple of 4. For example, encoding 'Man' (3 bytes: 0x4D, 0x61, 0x6E) produces 'TWFu' (4 Base64 characters). Encoding 'Ma' (2 bytes) produces 'TWE=' (4 characters with one padding =). Encoding 'M' (1 byte) produces 'TQ==' (4 characters with two padding =). This 4/3 expansion ratio explains why Base64-encoded data is about 33% larger than the original. The encoding is deterministic — the same input always produces the same output — and reversible without loss of information, making it an encoding scheme rather than encryption. Understanding this mechanism helps diagnose common issues: unexpected padding characters indicate input length issues, and garbled output usually means the wrong character set was used during encoding or decoding.

Real-world use cases for Base64 encoding

Base64 encoding solves a fundamental problem: how to transmit binary or special-character data through systems that only handle plain ASCII text. In web development, Base64-encoded images are embedded directly in HTML and CSS using data URIs, eliminating separate HTTP requests for small images like icons and decorative elements. Email protocols (SMTP, IMAP) use Base64 to encode attachments, allowing binary files to travel through text-based mail systems. OAuth 2.0 authentication headers encode credentials as Base64: 'Authorization: Basic dXNlcjpwYXNz' decodes to 'user:pass'. JSON APIs sometimes Base64-encode binary fields (like profile pictures or document thumbnails) to maintain pure JSON structure without requiring multipart/form-data uploads. Configuration management tools store secrets and API keys as Base64-encoded strings in environment variables and config files, avoiding issues with special characters breaking shell parsing. URL-safe Base64 variants replace + with - and / with _ to prevent encoding conflicts with URL syntax, commonly used in JWT tokens and API query parameters. SVG images embedded in HTML are often Base64-encoded to avoid external file dependencies. Understanding these use cases helps you decide when Base64 encoding is the right tool versus when alternatives like hex encoding, URL encoding, or direct binary transmission would be more appropriate.

Frequently Asked Questions (FAQs)

What is Base64 encoding?

Base64 is an encoding scheme that converts binary data or text into an ASCII string using 64 characters (A-Z, a-z, 0-9, +, /) plus padding (=). It expands data by ~33% but ensures the result contains only safe ASCII characters suitable for transmission through text-based systems like email, URLs, and JSON.

Is Base64 encoding the same as encryption?

No. Base64 is encoding, not encryption. Anyone can decode a Base64 string back to its original form — there is no key or password involved. Never use Base64 to hide or protect sensitive data. Use proper encryption (AES, RSA) for security. Base64 merely changes the representation format, not the confidentiality.

Why does Base64 output contain '=' characters?

The '=' characters are padding. Base64 encodes data in groups of 3 bytes into 4 characters. When the input length isn't divisible by 3, padding characters are added to make the output length a multiple of 4. One '=' means 2 input bytes were encoded; two '=' means 1 input byte was encoded.

Can I encode Unicode text and emojis?

Yes. The tool encodes UTF-8 text, which includes all Unicode characters: accented letters (é, ñ, ü), CJK characters (中文, 日本語), Arabic, Cyrillic, and emojis (🚀, 😀). The UTF-8 encoding of these characters is then Base64-encoded, preserving all information for accurate round-trip decoding.

What's the difference between standard and URL-safe Base64?

Standard Base64 uses '+' and '/' as two of its 64 characters. URL-safe Base64 replaces '+' with '-' and '/' with '_' to prevent conflicts with URL syntax. Standard Base64 is used in email and general data encoding; URL-safe Base64 is used in JWT tokens, API parameters, and data URIs embedded in URLs.

Is my text processed securely?

Yes. All encoding and decoding happens locally in your browser using JavaScript. Your text never leaves your device, is never transmitted to any server, and is never stored or logged.

Recently Used Tools