Last updated: June 2026
By CalcOrigin Editorial Team
About Base64 Encode / Decode
The Base64 Encode / Decode tool converts binary
data to and from text format.
Base64 encoding allows binary information, such
as images, files, or other data, to be represented using a set
of 64 printable ASCII characters, making it suitable for use in
systems and environments that handle text more reliably than raw
binary data. This is why Base64 is widely used in email
attachments, data URIs, JSON web tokens, and many API
authentication schemes where binary data must travel through
text-only channels.
The term Base64 originates from the use of 64 characters in the
encoding alphabet: uppercase letters A–Z, lowercase
letters a–z, digits 0–9, and two additional
characters, typically + and /. The = character is used as
padding. Each Base64 character represents exactly 6 bits of the
original data, which means that three bytes (24 bits) of binary
data are encoded as four Base64 characters.
Our Base64 Encode/Decode tool supports both
text and file encoding and decoding. You can encode plain text
with various character encodings including UTF-8, ASCII, and
UTF-16, or you can upload files such as images, PDFs, and
archives for encoding. All operations happen entirely within
your browser using client-side JavaScript, ensuring your data
never leaves your computer. This makes it an ideal tool for
developers, system administrators, and anyone who needs to work
with Base64 data securely without uploading sensitive
information to external servers.
How Base64 Encoding Works
The Base64 character set includes uppercase letters A–Z,
lowercase letters a–z, digits 0–9, and two
additional characters, usually + and /. The symbol = is
sometimes used as padding at the end of the encoded output to
ensure that the encoded string has the proper length. The
following table shows the Base64 characters and their
corresponding numeric values based on RFC 4648.
| 0: A |
8: I |
16: Q |
24: Y |
32: g |
40: o |
48: w |
56: 4 |
| 1: B |
9: J |
17: R |
25: Z |
33: h |
41: p |
49: x |
57: 5 |
| 2: C |
10: K |
18: S |
26: a |
34: i |
42: q |
50: y |
58: 6 |
| 3: D |
11: L |
19: T |
27: b |
35: j |
43: r |
51: z |
59: 7 |
| 4: E |
12: M |
20: U |
28: c |
36: k |
44: s |
52: 0 |
60: 8 |
| 5: F |
13: N |
21: V |
29: d |
37: l |
45: t |
53: 1 |
61: 9 |
| 6: G |
14: O |
22: W |
30: e |
38: m |
46: u |
54: 2 |
62: + |
| 7: H |
15: P |
23: X |
31: f |
39: n |
47: v |
55: 3 |
63: / |
Modern computers are byte-based (8 bits per byte), while Base64
encoding represents data using 6-bit values mapped to 64
characters. As a result, Base64-encoded data is typically about
&frac43; (≈1.33) times the size of the original data.
As an example, the simple text "Dog" can be encoded in Base64 as
"RG9n," as shown below.
| Input letter |
D |
o |
g |
| 8-bit decimal |
68 |
111 |
103 |
| Bits |
0 |
1 |
0 |
0 |
0 |
1 |
0 |
0 |
0 |
1 |
1 |
0 |
1 |
1 |
1 |
1 |
0 |
1 |
1 |
0 |
0 |
1 |
1 |
1 |
| 6-bit decimal |
17 |
6 |
61 |
39 |
| Encoded letter |
R |
G |
9 |
n |
In the example above, the three ASCII characters in "Dog" have a
total of 3 × 8 = 24 bits. This can be divided evenly into
four 6-bit blocks. In many cases, there will be remaining bits
at the end. In such situations, one or two "=" padding
characters are added to the end of the encoded result to
represent the missing bits. For example, "Do" can be encoded in
Base64 as "RG8=," as shown below.
| Input letter |
D |
o |
|
| 8-bit decimal |
68 |
111 |
| Bits |
0 |
1 |
0 |
0 |
0 |
1 |
0 |
0 |
0 |
1 |
1 |
0 |
1 |
1 |
1 |
1 |
0 |
0 |
Padding |
| 6-bit decimal |
17 |
6 |
60 |
| Encoded letter |
R |
G |
8 |
= |
Similarly, "Dogs" can be encoded in Base64 as "RG9ncw==", as
shown below.
| Input letter |
D |
o |
g |
s |
|
| 8-bit decimal |
68 |
111 |
103 |
115 |
| Bits |
0 |
1 |
0 |
0 |
0 |
1 |
0 |
0 |
0 |
1 |
1 |
0 |
1 |
1 |
1 |
1 |
0 |
1 |
1 |
0 |
0 |
1 |
1 |
1 |
0 |
1 |
1 |
1 |
0 |
0 |
1 |
1 |
0 |
0 |
0 |
0 |
Padding |
| 6-bit decimal |
17 |
6 |
61 |
39 |
28 |
48 |
| Encoded letter |
R |
G |
9 |
n |
c |
w |
== |
Understanding the Base64 encoding algorithm is valuable for
debugging encoding issues and for implementing Base64 in
environments without built-in support. The algorithm works by
processing input data in 3-byte groups, converting each group of
24 bits into four 6-bit indices, and mapping those indices to
the Base64 alphabet. When the input length is not a multiple of
3, padding is added to complete the final group. This systematic
approach ensures that any binary data can be reliably converted
to a text representation using only printable ASCII characters.
Common Uses of Base64
Email attachments: Originally, SMTP was
designed to transport only 7-bit ASCII characters. Encoding
binary data using Base64 encoding allows older
SMTP servers to correctly transmit attachments across the
internet without data corruption. This is defined in the MIME
(Multipurpose Internet Mail Extensions) standard and remains
widely used today.
Embedding binary data in text files: Text-based
formats are widely used in computer systems, especially for
transmitting data over the internet. Base64 enables the
embedding of binary data in these text files. For example,
binary data can be Base64-encoded and included in JSON or XML
files. Images or PDF files can also be Base64-encoded and
embedded in HTML or CSS using data URIs:
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
/>
Authentication tokens: Base64 is used
extensively in web authentication systems. JWT (JSON Web Tokens)
use Base64url encoding for the header, payload, and signature
components. Basic HTTP authentication also uses Base64 to encode
username and password pairs. These applications rely on Base64
converting binary data into universally transmittable text.
Database storage of binary data: Many databases
store binary data as Base64-encoded strings because text columns
are easier to query, index, and manipulate than binary columns.
While this increases storage requirements by about 33%, it
simplifies application development and data portability between
different database systems.
How to Use the Base64 Encode/Decode Tool
Using our Base64 Encode/Decode tool is
straightforward. For text encoding and decoding, simply enter
your text in the input area, select the appropriate character
encoding from the dropdown menu, and click either the "Encode"
or "Decode" button. The result appears instantly in the output
area with options to copy the result to your clipboard or
download it as a text file. The tool supports real-time feedback
with clear error messages if the input cannot be processed.
For file encoding and decoding, use the file upload section of
the tool. Click "Choose File" to select a file from your
computer, then choose whether to encode or decode. When decoding
files, you can specify the output file type (text or
binary/image) and the character encoding if decoding to text.
The tool processes everything locally in your browser, so your
files never leave your computer. This is particularly important
for sensitive documents where privacy matters.
The tool supports over 30 different character encodings
including UTF-8, ASCII, UTF-16, and various international
encoding standards. UTF-8 is the recommended default for most
use cases as it supports all Unicode characters and is the most
widely used encoding on the web. For specialized applications,
you can choose from CJK encodings like Big5 and Shift JIS, or
legacy encodings like ISO-8859 variants. The character encoding
selection ensures that text with special characters, accented
letters, or non-Latin scripts is encoded and decoded correctly.
Practical examples of using the tool include encoding a
configuration file for embedding in a JSON API response,
decoding a JWT token to inspect its contents, converting an
image to a data URI for use in an HTML email signature, and
troubleshooting Base64-encoded data received from a third-party
service. Each operation takes just seconds and provides
immediate visual feedback of the result.
Base64 Character Set and Padding Explained
The standard Base64 alphabet as defined in RFC 4648 consists of
64 characters: A–Z (26), a–z (26), 0–9 (10), +
(1), and / (1), totaling 64 characters. This alphabet was chosen
because these characters are universally present in ASCII and
most character encodings, and they are safe to transmit over
text-based protocols without escaping or transformation.
Padding in Base64 ensures that the encoded output has a length
that is a multiple of 4 characters. Since each group of three
bytes (24 bits) encodes to four Base64 characters (24 bits), any
remainder of one or two bytes requires padding. One remaining
byte (8 bits) encodes to two Base64 characters (12 bits)
followed by two = padding characters. Two remaining bytes (16
bits) encode to three Base64 characters (18 bits) followed by
one = padding character.
Padding is important for decoders to correctly process the
encoded data. Some decoders can handle missing padding by
inferring it from the data length, but RFC 4648 requires padding
for strict compliance. Our tool correctly handles both padded
and unpadded Base64 input when decoding, making it compatible
with a wide range of data sources. Understanding padding helps
you identify and fix issues when Base64 data from different
systems does not decode correctly.
Base64 vs Other Encoding Schemes
Base64 is one of several binary-to-text encoding schemes, each
with different characteristics.
Hexadecimal encoding (base16) uses 16
characters (0–9 and A–F) and doubles the data size,
making it simpler but less compact than Base64. Use our
Hex Calculator for hexadecimal
arithmetic and conversions.
Base32 uses 32 characters (A–Z and
2–7) and increases data size by 60%, making it less
efficient than Base64 but more human-readable and
case-insensitive. Base32 is commonly used for one-time passwords
and cryptographic key encoding where manual transcription may be
required.
Base64 offers the best efficiency among common
binary-to-text encodings with only 33% overhead. It is the most
widely used encoding for data transmission over text protocols.
URL encoding (percent-encoding) serves a
different purpose: it encodes special characters in URLs using %
followed by two hex digits. Our
URL Encode/Decode tool
handles URL-specific encoding needs.
ASCII85 (also called Base85) encodes data with
85 characters and achieves only 25% overhead, making it more
space-efficient than Base64. It is used in Adobe PostScript and
PDF files. However, Base64 remains more popular due to its
simpler implementation and universal support across programming
languages and platforms.
Base64 in Web Development and Data URIs
Data URIs allow web developers to embed binary data directly in
HTML or CSS documents using Base64 encoding. Instead of linking
to an external image file with an src attribute
pointing to a URL, you can embed the entire image as a Base64
string within the document itself. This reduces HTTP requests,
which can improve page load times for small assets. The
technique is also used for embedding fonts, icons, and other
small binary resources.
A typical data URI follows this format:
data:[mime-type];base64,[base64-encoded-data]. For
example, embedding a small PNG icon might look like:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA....
Data URIs are commonly used for small icons, fonts, and CSS
sprites where the overhead of an extra HTTP request outweighs
the 33% size increase from Base64 encoding. Many CSS frameworks
and icon libraries use this technique to reduce the number of
HTTP requests on page load.
Web developers should consider several factors when deciding
whether to use data URIs. For images smaller than 10 KB, data
URIs often improve performance by eliminating HTTP requests. For
larger images, the Base64 size overhead and lack of browser
caching may make external files more efficient. Data URIs also
cannot be cached separately from the containing document, so
every page load requires downloading all embedded resources
again. This means frequently accessed large images are better
served as separate cached files.
Another common use of Base64 in web development is in service
workers and offline applications. When building progressive web
apps that need to work without network connectivity, developers
often encode critical resources as Base64 strings and store them
in the service worker cache. This allows the application to
function fully offline by embedding all necessary assets
directly in the code.
Base64 in Email and MIME Attachments
The Simple Mail Transfer Protocol (SMTP) was originally designed
to handle only 7-bit ASCII text. When email evolved to support
attachments, a standard was needed to encode binary files such
as images, documents, and archives into text format. MIME
(Multipurpose Internet Mail Extensions) adopted Base64 as the
primary encoding for binary email attachments. Without Base64,
modern email with attachments would not be possible on legacy
SMTP systems.
When you send an email with an attachment, your email client
automatically Base64-encodes the file, wraps it with MIME
headers indicating the content type and encoding, and transmits
it as part of the email body. The receiving email client reads
the MIME headers and decodes the Base64 data back into the
original file. This process happens transparently to users, but
understanding it helps troubleshoot attachment issues.
MIME also supports quoted-printable encoding for text
attachments that are mostly ASCII with occasional non-ASCII
characters, and 7-bit or 8-bit transfer encoding for plain text.
Base64 is preferred for binary data because it reliably encodes
any byte sequence into safe ASCII characters.
Is Base64 Encryption? Security Misconceptions
A common misconception is that
Base64 encoding provides security or
encryption. Base64 is not encryption; it is an encoding scheme.
The difference is fundamental: encoding transforms data for
usability across different systems, while encryption transforms
data to prevent unauthorized access. Anyone with a Base64
decoder can instantly decode Base64-encoded data without any
key.
Base64 should never be used to protect sensitive information
such as passwords, credit card numbers, personal data, or
confidential documents. The Base64 encoding is trivially
reversible using built-in functions like atob() in
JavaScript or base64_decode() in PHP. Using Base64
for security is equivalent to storing data in plain text with a
simple transformation that provides no actual protection.
For actual security, use proper encryption algorithms such as
AES for data at rest or TLS for data in transit. Base64 may be
used as a transport encoding after encryption, meaning you
encrypt the data first and then Base64-encode the ciphertext for
transmission over text-based protocols. However, the Base64 step
adds no security value by itself.
Encoding Different Data Types with Base64
Base64 can encode any type of binary data. When encoding text,
the process first converts the text string to bytes using a
specified character encoding (UTF-8, ASCII, etc.), then applies
the Base64 algorithm to the byte sequence. This is why our tool
allows you to choose the character encoding for text operations.
The choice of encoding matters because different encodings
produce different byte representations of the same text,
resulting in different Base64 output.
Images are commonly Base64-encoded for
embedding in web pages, CSS, and email. PNG, JPEG, GIF, SVG, and
WebP images can all be encoded. The resulting Base64 string
includes all pixel data, metadata, and compression information
from the original file. An encoded 100 KB PNG image will produce
a Base64 string of approximately 137 KB. This size increase is
the trade-off for eliminating a separate HTTP request.
Documents such as PDF files, Word documents,
and Excel spreadsheets can be Base64-encoded for transmission in
JSON APIs or storage in text-based databases. This is common in
document management systems where binary files need to be stored
alongside text metadata in JSON or XML formats.
Archives like ZIP and RAR files,
audio files like MP3 and WAV, and
video files like MP4 can also be encoded. The
file type does not affect the encoding process since Base64
operates on raw bytes. Regardless of whether you are encoding a
small text file or a large video, the Base64 algorithm works the
same way, processing every byte of the input sequentially. Use
our
Conversion Calculator
for other unit and format conversions.
Common Mistakes to Avoid with Base64
Using Base64 for security: As discussed above,
Base64 is not encryption. Never use it to protect sensitive
data. A quick Base64 decode reveals the original data instantly.
Always use proper encryption algorithms for security purposes.
Wrong character encoding: When decoding Base64
to text, using the wrong character encoding produces garbled
output. If you encoded UTF-8 text, you must decode with UTF-8.
If you decode UTF-8 Base64 data using ASCII, non-ASCII
characters will appear as replacement characters or question
marks. Always verify that the character encoding matches between
encode and decode operations.
Handling padding incorrectly: Some systems
generate Base64 without padding (= characters), while others
require it. If your decoder fails, try adding or removing
padding. Our tool handles both cases automatically.
Ignoring URL safety: Standard Base64 contains +
and / characters, which have special meaning in URLs. If using
Base64 in URLs, query parameters, or file names, use the
URL-safe Base64 variant (Base64url) that replaces + with - and /
with _. Always verify which variant your application requires.
Excessive memory usage: Base64 encoding
increases data size by 33%. For very large files, consider
whether Base64 is the right approach. Streaming the Base64
conversion in chunks rather than loading the entire file into
memory can prevent browser or server crashes.
Assuming all Base64 is the same: Not all Base64
implementations use the same alphabet or rules. Some systems use
a different ordering of characters, different padding rules, or
custom alphabets for specific purposes. Always check the
documentation of the system generating the Base64 data to ensure
you are using the correct decoding method. Our tool supports
standard RFC 4648 Base64 and works with most common
implementations.
Forgetting about line breaks in MIME Base64:
Email systems and some configuration files format Base64 with
line breaks every 76 characters. If you copy Base64 data from an
email or config file and try to decode it without removing the
line breaks, the decoder may fail or produce incorrect output.
Our tool handles most line break scenarios automatically, but
removing extra whitespace before decoding is a good habit.
Not verifying decoded output: When decoding
Base64, always verify that the output matches your expectations.
Corrupted Base64 data, incorrect character encodings, or wrong
Base64 variants can produce garbage output without error
messages. For important data, compare checksums or hashes of the
original and decoded files to ensure integrity.
Base64 Variants: URL-Safe and Other Standards
Several Base64 variants exist for different use cases. The most
common is RFC 4648 Base64 (standard Base64)
which uses A–Z, a–z, 0–9, +, and / with =
padding. This is the default used by most programming languages
and is what our tool uses for standard encoding operations.
Base64url (URL-safe Base64) replaces + with -
and / with _, and typically omits padding. This variant is safe
for inclusion in URLs, query strings, and file names without
percent-encoding. JWT (JSON Web Tokens), OAuth access tokens,
and many web APIs use Base64url encoding. If you need to encode
data for a URL, you should use a
URL Encode/Decode tool or
the Base64url variant.
MIME Base64 inserts line breaks every 76
characters to comply with email standards. This variant is used
in email attachments and some configuration files. The line
breaks must be removed before decoding in most programming
environments. Other variants include modified
Base64 for XML/XSLT (using . and - instead of + and /) and
various proprietary implementations with custom alphabets.
Performance Considerations with Base64
Base64 encoding and decoding have computational costs that
should be considered in performance-sensitive applications. The
encoding process requires bit manipulation and table lookups for
every 3 bytes of input, while decoding reverses this process.
Modern browsers and programming languages implement highly
optimized Base64 algorithms, but processing very large files can
still impact performance. Understanding these performance
characteristics helps you make informed decisions about when and
how to use Base64 in your projects.
In web applications, Base64 affects performance in several ways.
The 33% increase in data size means more data to transmit over
the network, larger memory allocations, and longer processing
times. For small amounts of data (under 100 KB), the overhead is
negligible. For large files (over 10 MB), the performance impact
becomes significant and alternative approaches should be
considered. When working with large files, consider compressing
the data before Base64 encoding to minimize the total size.
Best practices for Base64 performance include processing data in
chunks or streams rather than loading entire files into memory,
using native Base64 functions (like btoa() and
atob() in browsers) rather than JavaScript
implementations, and avoiding unnecessary encode-decode round
trips. When embedding images in web pages, use data URIs only
for small assets and prefer external file references for larger
resources. In server-side applications, limit the size of Base64
payloads that your API will accept to prevent denial-of-service
attacks through excessively large encoded data.
Final Thoughts
Base64 encoding is an essential tool for
developers, system administrators, and anyone who works with
data transmission over text-based protocols. Understanding how
Base64 works, when to use it, and what common pitfalls to avoid
helps you use it effectively and appropriately in your projects.
From embedding images in web pages to handling email attachments
and API authentication, Base64 is a fundamental building block
of modern data exchange.
Our Base64 Encode/Decode tool provides a fast,
secure, and private way to encode and decode Base64 data
entirely in your browser. Whether you need to encode text,
decode files, embed images in web pages, or troubleshoot Base64
data from other systems, this tool handles all common Base64
operations with support for multiple character encodings and
file types. The browser-based processing ensures your sensitive
data never leaves your computer.
Remember that Base64 is encoding, not encryption. Use it for
data transmission and storage compatibility, not for security.
Choose the right variant for your use case (standard, URL-safe,
or MIME), and always verify character encodings when decoding
text. With the right understanding and tools, Base64 becomes a
powerful and reliable part of your data handling toolkit. Try
our tool above to see how easy Base64 encoding and decoding can
be.
To learn more about base64 encode decode, visit
Omni Calculator.
Frequently Asked Questions
What is Base64 encoding?
Base64 is a method of encoding binary data into text format
using 64 printable ASCII characters. It is commonly used to
transmit binary data over text-based protocols like email and
HTTP, or to embed binary data in text formats like JSON, XML,
HTML, and CSS. Each Base64 character represents 6 bits of data.
Is Base64 encryption?
No, Base64 is not encryption. It is an encoding scheme that
converts binary data to text format. Anyone can easily decode
Base64-encoded data using standard tools like this Base64
decoder. Base64 should never be used to protect sensitive
information because it offers no security whatsoever.
Why does Base64 output end with = or ==?
The = character is used as padding in Base64 encoding. When the
input data does not divide evenly into 6-bit blocks, one or two
= characters are added to make the output length a multiple of
4. One = indicates 2 bits of padding, and two = indicates 4 bits
of padding. The padding ensures the encoded data can be decoded
correctly.
Is my data safe when using this tool?
Yes, all encoding and decoding operations are performed locally
in your browser. No data is sent to any server. Your text,
images, and files never leave your computer, ensuring your
information remains private and secure. This makes our tool safe
for handling sensitive data.
How much larger is a Base64-encoded file?
Base64-encoded data is approximately 33% larger than the
original binary data. This is because Base64 encodes 6 bits of
data per character instead of 8 bits per byte. The exact
overhead depends on the input size and padding requirements. For
a 1 MB file, the Base64 output will be about 1.37 MB.
Can I Base64-encode images?
Yes, you can Base64-encode any image file including PNG, JPEG,
GIF, SVG, and WebP. Use the file upload section of our tool to
select an image file and encode it. The resulting Base64 string
can be used as a data URI to embed the image directly in HTML or
CSS without needing a separate file.
What is the difference between Base64 and URL encoding?
Base64 and URL encoding serve different purposes. Base64
converts binary data to text using 64 characters, while URL
encoding (percent-encoding) replaces special characters in URLs
with % followed by their hex code. Base64 is not URL-safe
because it contains +, /, and = characters, though URL-safe
Base64 variants exist that replace these with - and _.
What character encodings are supported for Base64 decoding?
Our tool supports a wide range of character encodings for Base64
decoding including UTF-8, ASCII, UTF-16, and many international
encodings such as Big5, GB 18030, EUC-JP, Shift JIS, KOI8-R, and
ISO-8859 variants. UTF-8 is the recommended default for most use
cases.
Is Base64 used in data URIs?
Yes, Base64 is commonly used in data URIs to embed images,
fonts, and other binary resources directly in HTML or CSS. A
data URI using Base64 looks like
data:image/png;base64,iVBORw0KGgo.... This technique reduces
HTTP requests but increases page size by about 33% for the
embedded resources.
What is URL-safe Base64?
URL-safe Base64 is a variant of Base64 that replaces the + and /
characters with - and _ respectively, and often omits padding =
characters. This makes the encoded string safe for use in URLs
and filenames without requiring percent-encoding. It is commonly
used in JWT tokens, web APIs, and filename generation.
Can I decode a Base64 string back to its original file?
Yes, you can decode a Base64 string back to its original file
using the file decode feature of our tool. Select "decode a
file" mode, provide the Base64 string, specify whether the
output is text or binary, and the tool will reconstruct and
download the original file. For images, the decoded file will be
the exact original.
Does Base64 work with all file types?
Yes, Base64 can encode any file type including documents (PDF,
DOCX), images (PNG, JPEG), archives (ZIP, RAR), audio (MP3,
WAV), and video (MP4, AVI). The encoding process works on the
raw binary data of the file, so the file type does not matter.
The decoded file will be identical to the original.