CalcPlatformPro
HomeFinanceHealthMathConstructionConvertersDateOtherFeedback
Feedback
CalcPlatform

Free, fast, and precise financial, mathematical, health, and engineering calculators.

Financial Suite

  • Mortgage Calculator
  • Auto Loan Calculator
  • Personal Loan Calculator
  • EMI Installment
  • SIP Wealth Growth
  • Compound Interest

Categories & Tools

  • Finance Hub
  • BMI Health Calculator
  • Percentage Calculator
  • Age Calculator
  • Math Category

Company & Legal

  • About Us
  • Privacy Policy
  • Terms & Conditions
  • Feedback & Contact
© 2026 CalcPlatform. All calculations run client-side for total privacy.
HomeotherBase64 Encoder / Decoder

Base64 Encoder / Decoder

Advanced client-side Base64 encoder and decoder. Converts text and drag-and-drop file assets into Base64 strings, RFC 4648 URL-Safe variants, and HTML/CSS Data URIs.

Variant:
41 chars | 41 B
56 chars | 56 B
Input Size41 Bytes41 characters
Encoded Size56 Bytes56 characters
Overhead Expansion Ratio+36.59%Standard 4:3 size bloat
Line Breakdown1 LineContinuous stream
RELATED CALCULATORS:
URL Encoder / Decoder

1. What Is Base64 Encoding?

Base64 is a binary-to-text encoding method used to represent arbitrary bytes with a restricted set of ASCII characters. It is particularly useful when binary data needs to pass through systems, formats or interfaces that are designed primarily for text.

Base64 is not encryption, compression, or hashing. The encoding is reversible: if the encoded data is valid and the decoder knows the correct variant, the original bytes can be recovered. RFC 4648 defines the standard Base64 encoding and its alphabet.

This distinction matters in practical work. A Base64 string may look obscure, but it does not become secret merely because the bytes have been represented as letters, numbers and a few punctuation characters.

This Base64 Encoder / Decoder is designed for both ordinary text and binary data. It supports UTF-8 text, arbitrary file bytes, Standard Base64, the URL-safe Base64 variant, MIME-style line wrapping, independent line processing and Data URI generation. The production implementation has been regression-tested across ASCII, Unicode, emoji, binary payloads, URL-safe conversions, MIME boundaries and file round trips.

2. How the Base64 Algorithm Works

Base64 operates on bytes rather than directly on human-readable characters.

The basic transformation is:

3 bytes → 24 bits → four 6-bit groups → four Base64 characters

Each 6-bit group has a value from 0 through 63. Those values are mapped to the Base64 alphabet.

The standard alphabet is:

  • A–Z (index values 0–25)
  • a–z (index values 26–51)
  • 0–9 (index values 52–61)
  • + (index value 62)
  • / (index value 63)

That gives exactly 64 symbols. RFC 4648 specifies this alphabet and also defines the URL-safe variation discussed later in this guide.

Conceptually, a 24-bit block can be viewed as:

aaaaaaaa bbbbbbbb cccccccc
which is regrouped as:
aaaaaa aabbbb bbbbcc cccccc

Each six-bit value is then converted to its corresponding Base64 symbol.

This is why Base64 increases the textual representation size: three input bytes become four output characters.

3. Worked Example: Encoding “Man” as Base64

A classic test vector is:

Man

The ASCII byte values are:

M = 77 (0x4D)
a = 97 (0x61)
n = 110 (0x6E)

In binary:

01001101 01100001 01101110

Grouping those 24 bits into four 6-bit values gives:

010011 | 010110 | 000101 | 101110

The decimal indexes are:

19, 22, 5, 46

Those map to:

T, W, F, u

Therefore:

Man → TWFu

This is the type of direct transformation performed by the calculator.

The reverse operation reconstructs the original bytes:

TWFu → Man

The production test suite independently verified this result along with other standard vectors.

Transformation StepByte 1 ('M')Byte 2 ('a')Byte 3 ('n')
1. ASCII CharacterMan
2. Decimal Value7797110
3. 8-Bit Binary Stream010011010110000101101110
4. 6-Bit Regrouping010011010110000101101110
5. Base64 Index (0–63)1922546
6. Encoded OutputTWFu

4. Base64 Padding: Why “=” Appears at the End

Base64 works most naturally with input groups of three bytes. When the final group contains fewer than three bytes, padding is added.

Examples:

M → TQ==
Ma → TWE=
Man → TWFu

The reason is structural rather than semantic. Base64 always represents a complete output group, so missing input bits are handled according to the encoding rules and the resulting output is padded with = where necessary. RFC 4648 specifies the padding behavior and also explains situations where a referring specification may omit padding.

For input byte count N, the standard padded Base64 output length is:

4 × ceil(N / 3)

So:

  • 1 byte → 4 Base64 characters (2 value chars + 2 padding chars “==”)
  • 2 bytes → 4 Base64 characters (3 value chars + 1 padding char “=”)
  • 3 bytes → 4 Base64 characters (4 value chars + 0 padding chars)
  • 4 bytes → 8 Base64 characters
  • 5 bytes → 8 Base64 characters
  • 6 bytes → 8 Base64 characters

The number of actual data characters and the number of padding characters depend on N mod 3.

The calculator specifically verifies the 1-byte, 2-byte and 3-byte cases as well as larger randomized inputs.

5. Standard Base64 vs Base64URL

Standard Base64 and Base64URL are closely related, but they are not identical formats.

Standard Base64 uses:

+
/

for its final two alphabet positions.

The URL-safe Base64 variant replaces them with:

- (hyphen)
_ (underscore)

RFC 4648 defines the URL- and filename-safe Base64 alphabet specifically to avoid characters that have special meanings or awkward handling in URLs and filenames. It also notes that Base64URL should not simply be treated as the same thing as ordinary Base64. When the data will be placed into a URL, the URL Encoder / Decoder is the more appropriate companion tool for URL percent-encoding rather than Base64.

The calculator supports both variants.

For URL-safe encoding, the current implementation removes trailing = padding and restores the required padding during decoding. This behavior is explicitly tested against randomized URL-safe inputs.

That distinction is particularly useful when Base64 data appears in:

  • URL parameters
  • filenames
  • compact tokens
  • JSON Web Tokens
  • other web-oriented representations

6. Base64URL Is Used in JWTs

JSON Web Tokens are a common place where Base64URL appears.

A compact JWT has multiple dot-separated parts, and RFC 7519 specifies that each part contains a Base64URL-encoded value.

A JWT therefore resembles:

header.payload.signature

The important security point is that Base64URL itself does not encrypt the header or payload.

The cryptographic properties come from the signing or encryption mechanisms associated with the JOSE/JWT implementation, not from the Base64URL representation. RFC 7519 distinguishes signed/MACed JWTs from encrypted JWE structures.

So decoding a JWT payload is not the same thing as breaking encryption.

7. Base64 and UTF-8: Why Unicode Needs Special Handling

A common misconception is that Base64 is inherently a text encoding.

It is more accurate to say that Base64 encodes bytes. Text must first be converted to bytes using a character encoding such as UTF-8.

This becomes important for characters outside basic ASCII.

For example:

é is represented in UTF-8 as two bytes: C3 A9 → Base64: w6k=
€ uses three UTF-8 bytes: E2 82 AC → Base64: 4oKs
😀 uses four UTF-8 bytes: F0 9F 98 80 → Base64: 8J+YgA==

The production calculator explicitly tests accented characters, CJK text, emoji and mixed Unicode strings, including exact round trips back to the original text.

8. JavaScript btoa() and the Unicode Trap

Browser developers sometimes discover that:

btoa("Hello")

works while a direct call such as:

btoa("😀")

does not.

That happens because the browser btoa() API operates on a binary-string representation rather than automatically treating an arbitrary JavaScript Unicode string as a UTF-8 byte sequence. MDN specifically documents this distinction and recommends converting text to UTF-8 bytes first when arbitrary Unicode text is involved.

A safer conceptual pipeline is:

Encoding: Unicode text → UTF-8 encoding → bytes → Base64
Decoding: Base64 → bytes → UTF-8 decoding → Unicode text

That is also why this calculator reports byte counts separately from character counts. For example, the production audit confirms that the emoji 😀 is correctly measured as four UTF-8 bytes rather than merely relying on JavaScript's UTF-16 string length.

For a browser implementation that must handle Unicode reliably, TextEncoder and TextDecoder are appropriate tools in this pipeline. MDN discusses this approach explicitly.

9. Base64 for Files and Binary Data

Base64 becomes especially useful when the source is not text at all.

Images, PDFs, audio files, compressed assets and arbitrary binary payloads can all be represented as Base64 because the algorithm operates on bytes.

The important rule is:

file bytes → Base64 (not: file → filename → Base64)

The calculator's file mode therefore measures the actual file byte size using the file's size property. This was specifically corrected and then verified with a 1 MB fixture and additional file-size cases.

The tool's regression suite also verifies exact byte-for-byte round trips for deterministic binary data and supported example file types such as PNG, JPEG, SVG, WebP, PDF and audio data.

This matters because attempting to interpret arbitrary binary data as ordinary text before encoding can corrupt the original bytes.

10. Base64 Size Overhead: Why the Output Gets Larger

Base64 is convenient, but it is not space-efficient.

The basic relationship is:

3 bytes → 4 Base64 characters

For large payloads, the output therefore approaches approximately:

4 / 3 ≈ 1.3333 (+33.33% expansion)

The exact percentage for small inputs varies because of padding.

For example, ignoring any line-break overhead:

  • 1 byte → 4 encoded characters (+300% expansion)
  • 2 bytes → 4 encoded characters (+100% expansion)
  • 3 bytes → 4 encoded characters (+33.33% expansion)

The calculator reports the actual input size, output size and expansion ratio rather than blindly displaying +33.33% for every payload. Its audit specifically verifies +300% for one-byte input, +100% for two bytes and approximately +33.33% for three bytes and large inputs.

11. MIME Base64 and 76-Character Lines

MIME introduced conventions for representing binary data in email-oriented text bodies.

RFC 2045 specifies that Base64 encoded output in this context should be represented in lines no longer than 76 characters, excluding the line-ending characters.

For example, a long Base64 string may be transformed into:

[76 characters]
[76 characters]
[remaining characters]

The line breaks are formatting around the encoded stream; they are not additional Base64 data.

The calculator supports 76-character chunking and independently tests boundary cases such as 75, 76, 77, 152, and 156 encoded characters.

This is useful when preparing output for systems that expect MIME-style formatting. It should not, however, be mistaken for a universal requirement for every Base64 string used on the web.

12. Processing Each Line Independently

There are two different ways to treat multiline input.

Continuous stream:

The complete text, including newline bytes, is encoded as one byte stream. For “Hello\nWorld”, the newline is part of the encoded data.

Independent line processing:

Each line is encoded separately. For example:

Hello → SGVsbG8=
World → V29ybGQ=

These are different representations because the newline is not handled in the same way.

The calculator supports an explicit per-line processing option and preserves empty lines exactly. For example, “A\n\nB” round-trips as “A\n\nB” without silently collapsing the blank line. The final regression suite includes 10,000 randomized multiline blank-line tests.

That distinction is important when Base64 is being used to process structured text where line boundaries are meaningful.

13. Data URLs and Base64

A Data URL embeds data directly into a URL-like resource identifier.

RFC 2397 defines the syntax:

data:[mediatype][;base64],data

For Base64 content, a typical example is:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...

The ;base64 marker indicates that the data portion is Base64 encoded.

Data URLs can be useful for small inline resources such as:

  • images and micro-icons
  • embedded vector assets
  • generated preview content
  • quick prototypes

They are not automatically the best choice for large assets. The Base64 representation itself introduces overhead, and very long inline data can make documents, stylesheets or URLs unwieldy.

The calculator can produce an asset Data URI from supported file inputs and verifies that the encoded payload can be extracted and round-tripped correctly.

14. HTTP Basic Authentication and Base64

HTTP Basic Authentication is another well-known Base64 use case.

RFC 7617 defines the scheme in which the user-id and password are combined into a credential string and that byte sequence is encoded with Base64.

Conceptually:

username:password → Base64(username:password)

and is then placed in an authorization header:

Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=

However, Base64 does not provide confidentiality.

RFC 7617 explicitly explains that Basic Authentication is not considered secure unless it is used with an external secure mechanism such as TLS because the credentials are effectively exposed if intercepted.

Therefore:

Base64 encoding ≠ encryption. Do not use a Base64 encoder as a password-protection mechanism.

15. Base64 Is Not Encryption

This is one of the most important concepts to understand.

Base64 is encoding, not encryption.

Encoding is designed to represent information in another format.

Encryption is designed to transform information using a cryptographic process so that unauthorized parties cannot recover the protected plaintext without the required key or cryptographic capability.

Base64 has no secret key. Anyone with the encoded string and a suitable decoder can normally recover the original bytes.

That is why the calculator's educational content explicitly distinguishes Base64 from encryption, authentication and cryptographic integrity mechanisms.

Never store passwords as Base64. For password storage, use a purpose-built password hashing scheme with appropriate salting and work factors (such as Argon2id, scrypt or bcrypt) rather than reversible encoding.

16. Base64 and Data Integrity

Base64 also does not provide cryptographic integrity verification, tamper detection, authentication, or encryption.

If an encoded string is modified, a decoder may:

  • reject it
  • produce different bytes
  • or, depending on the implementation and exact mutation, still decode some partial result

The Base64 transformation itself does not tell you whether the bytes were tampered with.

Integrity and authenticity normally require separate mechanisms such as cryptographic hashes, MACs or digital signatures, depending on the application.

This distinction is especially important for JWTs: the token's cryptographic security comes from the signature/MAC or encryption mechanism, not simply from the fact that its segments use Base64URL. RFC 7519 explicitly separates the representation from the cryptographic operations applied to the token.

17. Invalid Base64 and Whitespace

Valid Base64 uses a defined alphabet.

In strict contexts, characters outside the permitted alphabet should not simply be ignored. RFC 4648 says implementations should reject non-alphabet characters unless the referring specification explicitly allows a different treatment; MIME is one example where line breaks and certain whitespace handling are part of the surrounding convention.

The calculator therefore distinguishes malformed Base64 from valid input and produces explicit validation errors rather than fabricating decoded output.

Examples of inputs that should trigger validation include malformed padding and illegal characters.

The production audit confirms strict rejection of invalid symbols and malformed padding while supporting the intended whitespace behavior for supported decoding scenarios.

18. How to Use the Base64 Encoder / Decoder

Encode text:

  1. Select Text Convert.
  2. Enter your text.
  3. Choose the required variant (Standard or URL-Safe).
  4. Choose the character encoding option where applicable (UTF-8, ASCII, Latin-1, UTF-16).
  5. Review the dynamically updated encoded output.
  6. Copy or download the result.

For ordinary UTF-8 text, the conceptual process is:

Text → UTF-8 bytes → Base64

Decode Base64:

  1. Select Decode mode using the segmented toolbar pill.
  2. Paste the Base64 string into the input area.
  3. Choose the matching variant (Standard or URL-Safe).
  4. Review the decoded plaintext output and character counts.
  5. Use Swap to switch input and output if needed.

For Unicode:

Base64 → bytes → UTF-8 text

Convert a file:

  1. Select File to Base64 (Data URI) tab.
  2. Drop a file or choose one using the file picker.
  3. Review the exact file byte size and Base64 encoded size.
  4. Select your preferred output format: Data URI, Raw Base64, HTML <img>, or CSS background.
  5. Copy the snippet or download the encoded asset.

The implementation processes supported files client-side and the audit confirmed zero external network transmission of local file payloads.

Frequently Asked Questions

Clear, mathematically verified answers to common questions about Base64 encoding, decoding, Unicode, Data URIs, and network transmission.

Base64 is used to represent binary data as text using a restricted character set. Common applications include data transport in text-oriented systems, MIME content, Data URLs, embedded assets and protocol-specific representations. RFC 4648 defines the general Base64 encoding, while other specifications define particular contexts in which Base64 is used.
No. Base64 is reversible encoding, not encryption. It does not provide confidentiality or a secret key. Anyone who has the encoded data can generally decode it.
No. Passwords should not be stored as Base64 because Base64 is reversible. Password storage requires a dedicated password-hashing approach rather than a reversible encoding. The calculator's security guidance explicitly warns against Base64 password storage.
Standard Base64 uses + and /, while Base64URL replaces them with - and _ for URL- and filename-friendly use. RFC 4648 defines Base64URL as a distinct variant rather than simply another name for standard Base64.
Base64 maps every group of three input bytes to four output characters. As payload size becomes large, the expansion approaches approximately 33.33%, although small inputs can have much higher percentage expansion because of padding.
Convert the Unicode text to UTF-8 bytes first, then Base64-encode those bytes. This avoids the limitations of treating JavaScript Unicode strings as one-byte binary strings. MDN specifically recommends a byte-oriented approach for arbitrary Unicode text.
The = character is padding. It appears when the input length is not a multiple of three bytes and helps complete the final Base64 output group according to the encoding rules. RFC 4648 specifies this behavior.
TWFu → Man. It is the classic Base64 example produced by encoding the three ASCII bytes representing M, a and n.
SGVsbG8= → Hello. The final = is padding because the five-byte input does not divide evenly into three-byte encoding groups.
Browser btoa() expects a binary-string style input in which each character represents a single byte. Arbitrary Unicode characters can require multiple UTF-8 bytes, so direct use of btoa() on such text can throw an error. MDN recommends converting the text to UTF-8 bytes before Base64 encoding.
A Data URI is a data: URL that contains the data inline. With Base64 content it follows the general form: data:[media-type][;base64],<payload>. For example: data:image/png;base64,... RFC 2397 defines this URI scheme.
In MIME Base64, RFC 2045 specifies encoded lines no longer than 76 characters, excluding the line-ending sequence. This is a MIME formatting convention rather than a universal requirement for every Base64 string.
File size is the number of source bytes. Base64 size is the size of the encoded representation. Because Base64 expands data, the encoded representation is normally larger than the source. The calculator reports these as separate metrics and uses the actual file byte count rather than the filename length.
Yes. Base64 itself represents bytes and does not inherently contain the original filename or complete file metadata. To reconstruct a useful file, you may also need its MIME type, file extension or other context.
Usually yes. Because Base64 characters represent groups of bits, changing a character can alter one or more reconstructed bytes. Whether decoding succeeds depends on whether the modified string still satisfies the format's syntax and padding rules.

Technical Notes and Limitations

This calculator is a representation and conversion tool, not a cryptographic security tool. Base64 should not be relied upon for:

  • confidentiality
  • password storage
  • authentication by itself
  • tamper detection
  • cryptographic integrity

Use the appropriate security mechanism for the application.

For Unicode text, make the byte encoding explicit. UTF-8 is the relevant byte representation for the calculator's text workflow, and the implementation independently validates multibyte characters and emoji.

For files, distinguish: filename, file metadata, and file bytes. The actual Base64 payload is derived from the file bytes. The verified implementation measures file mode input using File.size, not the length of the filename.

For MIME use, remember that 76-character wrapping belongs to the MIME convention. For URL use, use the explicitly URL-safe Base64 variant where required rather than manually replacing characters without considering the consuming protocol.

Standards and Technical References

RFC 4648 — The Base16, Base32, and Base64 Data Encodings

Defines standard Base64, padding rules, treatment of non-alphabet characters and the URL- and filename-safe Base64 alphabet.

RFC 2045 — MIME Part One

Defines MIME Base64 formatting requirements, including the 76-character encoded-line limit.

RFC 2397 — The “data” URL Scheme

Defines the data: URL syntax and the ;base64 form used for inline binary representations.

RFC 7617 — The “Basic” HTTP Authentication Scheme

Defines HTTP Basic Authentication and its use of Base64 for credential representation, while explaining the need for TLS for secure deployment.

RFC 7519 — JSON Web Token (JWT)

Defines JWT compact representation and the use of Base64URL-encoded token parts.

MDN Web APIs — btoa() and atob()

Documents browser Base64 encoding/decoding behavior and the need for explicit UTF-8 byte handling for arbitrary Unicode text.