Base64 Converter

Encode and decode text, files, and images instantly.

Input
|

The Ultimate Guide to Base64 Encoding

Base64 is a group of binary-to-text encoding schemes that represent binary data in an ASCII string format by translating it into a radix-64 representation. It is designed to carry data stored in binary formats across channels that only reliably support text content.

How Base64 Works

The Base64 alphabet consists of 64 characters: A-Z, a-z, 0-9, and usually + and /.

It takes 3 bytes of binary data (24 bits) and splits them into four 6-bit chunks. Each 6-bit chunk maps to one of the 64 characters in the Base64 index table. If the binary data isn't divisible by 3, padding characters (=) are added to the end.

Common Use Cases

  • Data URIs: Embedding small images (logos, icons) directly into HTML or CSS to reduce HTTP requests.
  • Email Attachments: Sending binary files (PDFs, images) via MIME over text-based email protocols.
  • Authorization: Basic Auth headers in HTTP requests (`Authorization: Basic base64(user:pass)`).

Base64 vs. Hexadecimal

Feature Base64 Hexadecimal
Characters 64 (A-Z, a-z, 0-9, +, /) 16 (0-9, A-F)
Efficiency 4 chars for 3 bytes (~33% overhead) 2 chars for 1 byte (100% overhead)
Use Case Binary data transfer (Images, Files) Debugging, Colors, Memory Addresses

Is Base64 Encryption?

WARNING: Base64 is NOT Encryption

Base64 is an encoding scheme, not encryption. It does not secure data. Anyone can decode a Base64 string back to its original form without a key. Do not use Base64 to hide passwords or sensitive information unless it is also encrypted or hashed first.

Data URI Syntax

To embed a Base64 image in HTML, use the following syntax:

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAU..." alt="Embedded Image" />

Base64 FAQ

What is Base64 encoding?

Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format using 64 different characters.

How to encode text to Base64?

Paste your text into the N28 Base64 Converter and click 'Encode'. The tool converts your string into a Base64 format instantly.

How to decode Base64 to text?

Paste the Base64 string into the converter and click 'Decode' to reveal the original readable text.

How to convert image to Base64?

Upload your image to the 'Image' tab on N28. The tool will generate a data URI string (starting with data:image/...) representing your image.

Does Base64 increase file size?

Yes. Base64 encoding typically increases the data size by approximately 33% compared to the original binary data.

Is Base64 encryption?

No. Base64 is an encoding scheme, not encryption. It does not secure data; it simply changes its representation. It can be easily decoded by anyone.

Why use Base64 for images?

Base64 allows you to embed images directly into HTML or CSS files, reducing the number of HTTP requests required to load a page.

What characters are in Base64?

The standard Base64 index table uses A-Z, a-z, 0-9, +, and /. The equals sign (=) is used for padding.

What is URL-safe Base64?

URL-safe Base64 replaces the '+' and '/' characters with '-' and '_' respectively to make the string safe to use in URLs and filenames.

How to debug Base64 strings?

If decoding fails, check for whitespace, line breaks, or missing padding characters (=) at the end of the string.

Can Base64 encode Emojis?

Yes, Base64 handles UTF-8 characters, including Emojis, provided the encoder supports multibyte strings correctly (like N28 does).

How to use Base64 in HTML?

Use the format: <img src='data:image/png;base64,YOUR_STRING_HERE'>.

How to use Base64 in CSS?

Use: background-image: url('data:image/png;base64,...');

What is data URI scheme?

The data URI scheme allows you to include data in-line in web pages as if they were external resources.

Is Base64 SEO friendly?

For small icons, yes. For large images, no. Google prefers standard image files for indexing and caching.

Maximum size for Base64?

Technically unlimited, but browsers have limits on URL length and memory. It is best used for small files (< 1MB).

How to decode Base64 in JavaScript?

Use the built-in function `atob('string')` for decoding and `btoa('string')` for encoding.

How to decode Base64 in Python?

Use the base64 library: `import base64; base64.b64decode(data)`.

How to decode Base64 in PHP?

Use the `base64_decode($string)` function.

What is Base64 padding?

Padding characters (=) are added to the end of the Base64 string to ensure its length is a multiple of 4.

Can I encode PDF to Base64?

Yes, you can convert any binary file, including PDFs, into a Base64 string for transmission or storage.

Why do emails use Base64?

MIME (Multipurpose Internet Mail Extensions) uses Base64 to transmit binary attachments (images, docs) over text-based email protocols.

Is Base64 compression?

No, it is the opposite. It increases size. Do not use it to compress files.

Does Base64 hide data?

It obscures data from human reading but does not protect it securely. Anyone can decode it.

Can I base64 encode a password?

You can, but you should not use it for security. Use hashing (bcrypt, argon2) for passwords.

How to fix 'Invalid Character' error?

This usually happens when trying to decode a string that contains characters not in the Base64 alphabet. Check for spaces or newlines.

Base64 vs Hex encoding?

Base64 is more compact (4 chars for 3 bytes) than Hex (2 chars for 1 byte). Base64 is better for binary data transmission.

Can I use Base64 in JSON?

Yes, since JSON creates text-based data structures, Base64 is the standard way to include binary data inside JSON.

What is Base32?

Base32 is similar but uses a 32-character set. It is case-insensitive but less efficient than Base64.

Does Base64 support UTF-16?

Standard `btoa` in JS only supports ASCII. For UTF-16 strings, you need to encode them first (e.g., using TextEncoder).

Is Base64 reversible?

Yes, Base64 encoding is a lossless process. You can always get the exact original data back.

How to convert Base64 to Image online?

Paste your Base64 string into the 'Image' tab of the N28 converter to see the preview instantly.

What is the 'data:' prefix?

It is the scheme identifier for Data URIs, telling the browser that the following string is inline data.

Can Base64 contain newlines?

MIME Base64 allows newlines every 76 characters, but standard web usage usually requires a single continuous string.

How to encode audio to Base64?

Similar to images, audio files can be read as binary and converted to a `data:audio/mp3;base64...` string.

Is this tool private?

Yes. Your data (text or images) is processed locally in your browser. N28 does not upload your files.

How to convert Base64 to PDF?

You can decode the string to binary and save it with a .pdf extension using server-side code or Blob objects in JS.

What is Base58?

Base58 is used in cryptocurrencies (like Bitcoin). It removes ambiguous chars like 0, O, l, I to avoid confusion.

Does Base64 support Chinese characters?

Yes, if the characters are properly encoded to bytes (UTF-8) before Base64 conversion.

Can I base64 encode a file?

Yes, use the 'Image/File' tab on N28 to upload any file type and get its Base64 string representation.