Base64 Converter

Encode text to Base64 and decode Base64 to text

Base64 Encoded

Enter input above

About Base64

Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format. It is commonly used when there is a need to encode binary data that needs to be stored and transferred over media designed to deal with text. Common uses include email attachments, data URLs, and API tokens.

What Is Base64 Encoding?

Base64 encoding is a binary-to-text encoding scheme that represents binary data as a string of 64 printable ASCII characters. The Base64 alphabet consists of uppercase letters A-Z (values 0-25), lowercase letters a-z (values 26-51), digits 0-9 (values 52-61), and the plus sign (+, value 62) and forward slash (/, value 63). The equals sign (=) is used as padding when the encoded output is not a multiple of 4 characters.

Base64 is the most widely used binary-to-text encoding on the internet. It was originally defined in RFC 4648 and is employed wherever binary data needs to be stored or transmitted over media designed for text. The encoding expands the original data by approximately 33%, meaning every 3 bytes of binary input produce 4 characters of Base64 output.

The primary use cases for Base64 include email attachments (MIME encoding), data URLs in web pages, API authentication tokens, embedding images in HTML or CSS, and encoding JWT (JSON Web Token) payloads. Understanding Base64 is essential for web developers, API integrators, and anyone working with data serialization.

How Base64 Encoding Works

Base64 encoding converts binary data to text by grouping input bits into 6-bit chunks and mapping each chunk to a character in the Base64 alphabet. Because 6 bits can represent 64 different values (2⁶ = 64), the encoding uses exactly 64 characters.

Base64 Encoding Process

Every 3 bytes (24 bits) → 4 Base64 characters

Where:

  • Input= Original binary data in 8-bit bytes
  • 6-bit groups= Input bits regrouped into sets of 6
  • Output= Base64 string with = padding to multiple of 4

Common Uses of Base64

Base64 encoding appears throughout modern computing and the internet. Understanding where and why it is used helps developers work effectively with APIs, web technologies, and data serialization.

Use Case How Base64 Is Used
Email AttachmentsMIME encoding converts binary attachments to Base64 for transport over SMTP
Data URLsEmbed images directly in HTML/CSS using data:image/png;base64,...
API TokensJWT tokens encode header and payload as Base64
HTTP Basic AuthUsername:password pair is Base64-encoded in the Authorization header

How to Use This Calculator

The Base64 converter supports both encoding and decoding operations:

  1. Select the mode: Click "Encode" to convert text to Base64, or "Decode" to convert Base64 back to text.
  2. Enter the input: Type or paste your text (for encoding) or Base64 string (for decoding) into the text area.
  3. View the result: The converted output appears below, with a "Copy" button for convenience.
  4. Check the statistics: For valid conversions, the input and output character counts are displayed, showing the expansion factor.

The converter handles UTF-8 text correctly, supporting international characters and emojis.

Real-World Applications

Base64 is ubiquitous in web development and APIs. When you authenticate to an API using HTTP Basic Auth, your username and password are Base64-encoded in the Authorization header. JWT (JSON Web Token) uses Base64URL encoding for its header and payload components. Understanding Base64 is essential for debugging API requests and constructing proper authentication headers.

In email systems, MIME (Multipurpose Internet Mail Extensions) uses Base64 to encode binary attachments. When you attach a PDF or image to an email, the mail client Base64-encodes it so it can travel over text-only email protocols. The encoded data appears as a block of seemingly random characters in the email source.

Front-end web development frequently uses data URLs, which embed Base64-encoded images directly in HTML or CSS files. This eliminates additional HTTP requests for small images like icons and logos, though it increases the overall document size by about 33%.

Worked Examples

Encoding Text to Base64

Problem:

Encode the string 'Hello, World!' to Base64.

Solution Steps:

  1. 1Convert each character to ASCII: H=72, e=101, l=108, l=108, o=111, ,=44, (space)=32, W=87, o=111, r=114, l=108, d=100, !=33
  2. 2Convert ASCII values to 8-bit binary: 01001000 01100101 01101100 ...
  3. 3Group into 6-bit chunks and map to Base64 alphabet
  4. 4Result: SGVsbG8sIFdvcmxkIQ==

Result:

'Hello, World!' encoded = SGVsbG8sIFdvcmxkIQ==

Decoding Base64 to Text

Problem:

Decode the Base64 string 'SGVsbG8sIFdvcmxkIQ==' back to text.

Solution Steps:

  1. 1Remove the padding characters (=): SGVsbG8sIFdvcmxkIQ
  2. 2Map each Base64 character to its 6-bit value
  3. 3Regroup into 8-bit bytes
  4. 4Convert bytes to ASCII characters: H, e, l, l, o, ,, (space), W, o, r, l, d, !

Result:

SGVsbG8sIFdvcmxkIQ== decoded = 'Hello, World!'

Base64 Expansion Ratio

Problem:

How large will the Base64 encoding of a 300-byte binary file be?

Solution Steps:

  1. 1Base64 encodes every 3 bytes into 4 characters (expansion ratio of 4/3 ≈ 1.333)
  2. 2Calculate encoded length: 300 × 4/3 = 400 characters
  3. 3Check if padding is needed: 300 is divisible by 3, so no padding needed
  4. 4Verify: 400 characters is exactly 300 × 4/3

Result:

A 300-byte file produces exactly 400 Base64 characters

Tips & Best Practices

  • Base64 expands data by about 33% — a 3-byte input always produces 4 characters of output
  • Trailing = signs indicate padding; they can be removed before decoding in most implementations
  • Base64 is not encryption — it provides zero security and is trivially reversible
  • Base64URL replaces +/ with -_ and removes padding for use in URLs and file names
  • JWT tokens use Base64URL encoding for their header and payload components
  • HTTP Basic Auth base64-encodes 'username:password' — never use it without HTTPS

Frequently Asked Questions

Standard Base64 uses + and / as the 62nd and 63rd characters, while Base64URL replaces them with - and _ respectively. Base64URL also omits the = padding characters. Base64URL is designed for embedding Base64 data in URLs and file names where + and / are problematic characters.
No, Base64 is an encoding, not encryption. It provides no security whatsoever — anyone can decode Base64 data trivially. Base64 is used for data transport and formatting, not confidentiality. If you need to secure data, use proper encryption (AES, RSA) in addition to or instead of Base64 encoding.
The equals sign is padding that ensures the output length is a multiple of 4. When the input length is not a multiple of 3 bytes, padding is added: one = means 2 bytes of input were encoded into 3 characters, and two = signs mean 1 byte was encoded into 2 characters. The padding can be safely ignored when decoding.
Base64 output is approximately 33% larger than the original binary data. For every 3 bytes of input, Base64 produces 4 characters of output. This expansion ratio (4/3) is inherent to the encoding scheme and cannot be reduced without losing the property of being a reversible, lossless encoding.
Base64 encodes raw bytes, not characters. To encode Unicode text, first convert it to a byte sequence using UTF-8 (or another encoding), then Base64-encode those bytes. The decoder reverses this process: Base64-decode to bytes, then interpret the bytes as UTF-8 to recover the original Unicode text.

Sources & References

Last updated: 2026-06-06

💡

Help us improve!

How would you rate the Base64 Converter?

<>

Editorial Note

MyCalcBuddy Editorial Team

This page is maintained as an educational calculator reference.

Source

Formula Source: NIST Guide to SI Units

by National Institute of Standards

UpdatedLast reviewed: May 2026
CheckedFormula checks are based on standard references and internal QA review.