Base64 Encoder / Decoder

Convert text to Base64 or decode Base64 back to readable text. Everything runs in your browser, so the input never leaves the page.

Base64 output

Encoded output uses only the 64 Base64 symbols plus padding; decoded output is shown as readable UTF-8 text.

Encoded size at a glance

Input Base64 characters Growth
3 bytes433% larger
100 bytes13636% larger
1 KB (1,024 bytes)1,36834% larger
10 KB (10,240 bytes)13,65633% larger
1 MB (1,048,576 bytes)1,398,10433% larger

Calculated with 4 × ceil(bytes ÷ 3). Line breaks in MIME output add a few more characters.

Rate this Tool

0.0/5

Based on 0 user ratings.

Base64 is a transport format, not a security feature

Base64 exists so binary data can pass through channels that only accept printable text. It changes the representation of the bytes, not their meaning, and anyone holding the string can turn it back into the original.

How Base64 encoding works

The alphabet contains 64 characters: A–Z (26), a–z (26), 0–9 (10), plus + and /. Because 64 equals 26, every character represents exactly six bits.

The encoder reads the input three bytes at a time. Three bytes are 24 bits, and 24 divides evenly into four groups of six. Each group selects one alphabet character, so three bytes in become four characters out. The mapping is fixed and public, which is why the same input always encodes to the same string.

When the input length is not a multiple of three, the last group is padded with zero bits and the missing bytes are marked with =. One leftover byte yields two characters followed by ==; two leftover bytes yield three characters followed by a single =.

encoded characters = 4 × ceil(input bytes ÷ 3)
24 bits in, 4 characters out 0x48 = H 01001000 0x69 = i 01101001 0x21 = ! 00100001 the 24 bits are regrouped as four 6-bit indexes 18 → S 010010 6 → G 000110 36 → k 100100 33 → h 100001 "Hi!" encodes to SGkh

Check it by hand: Hi! is the byte sequence 0x48 0x69 0x21. In binary that is 01001000 01101001 00100001, regrouped as 010010 000110 100100 100001 = 18, 6, 36, 33. Those indexes land on S, G, k, h, so the result is SGkh. A five-byte word such as Hello needs padding and becomes SGVsbG8=.

Why Unicode text needs extra care

JavaScript's btoa() expects a binary string: every character code must be 255 or lower. Passing accented letters, curly quotes, emoji or non-Latin scripts straight into it throws an InvalidCharacterError, which is the most common reason a Base64 tool "works for English but fails for everything else".

The script on this page converts the string to UTF-8 bytes first using encodeURIComponent(), then hands those bytes to btoa(). Decoding reverses the route: atob() rebuilds the byte string and decodeURIComponent() interprets it as UTF-8.

That detail explains a frequent surprise. café stored as UTF-8 encodes to Y2Fmw6k=, while the same word stored in a legacy Windows code page encodes to something different. If two systems disagree about the encoding of the source bytes, they will disagree about the Base64 too.

Where Base64 shows up in real systems

UsageWhat is encodedWhy Base64
Data URISmall images, fonts, iconsLets HTML or CSS carry the asset in one request
JSON payloadFiles or binary fieldsJSON strings cannot hold raw bytes
HTTP Basic authUsername and passwordThe header value must be visible ASCII
Email attachmentsAny file, MIME encodedSMTP was designed for text
JWT segmentsHeader and claims JSONTokens travel in headers and URLs
PEM certificatesDER-encoded keys and certsText blocks survive copy and paste

Basic authentication is the case people misread most often. The credentials are Base64, not encrypted, so the header is readable by anyone who can see the request. Transport encryption is what protects it, never the encoding itself.

Base64 vs encryption vs hashing

OperationReversible?Needs a key?
Base64 encodingYes, by anyoneNo
EncryptionOnly with the keyYes
HashingNoNo, but a salt is common
Rule of thumb: if the output can be decoded with a public table and no key, it is encoding. Never use Base64 to hide a password, a token or personal data.

URL-safe Base64, padding and line breaks

Standard Base64 uses + and /, which have reserved meanings inside URLs and file names. RFC 4648 defines a URL-safe variant that swaps them for - and _. Some systems also drop the = padding, because the decoder can reconstruct it from the string length. A JWT is the best-known example: its segments are Base64url without padding.

MIME email wraps encoded content at a fixed line length, so the same file can appear with hard line breaks every 76 characters. Those breaks are formatting, not data, but a strict decoder may reject them. This tool trims whitespace at both ends of the input before decoding, which covers the most common copy-and-paste case.

Typical failure messages and what they mean:

  • Invalid character: the string contains a symbol outside the alphabet, often a stray quote or a data-URI prefix such as data:image/png;base64,.
  • Incorrect length or padding: characters were dropped, or = signs were removed from a decoder that requires them.
  • Garbled output: the decode succeeded but the bytes were never UTF-8 text, for example when decoding an encoded image.

Related Developer & Security Tools

Tool What does it do? Action
Base64 Encoder & Decoder Encode text to Base64 or decode a Base64 string back to plain text. Current Page
Hash Generator Create MD5, SHA-1, SHA-256 and SHA-512 hashes from text. Hash Maker →
UUID Generator Generate random UUID v4 values, one or many at a time. UUID Maker →
Password Generator Build strong random passwords with length and character options. Password Maker →
Regex Tester Test a regular expression against sample text and inspect the matches. Regex Test →
JWT Decoder Decode a JWT header and payload locally, without sending the token anywhere. JWT Decode →

Frequently Asked Questions

No. Base64 is a reversible encoding with a public alphabet and no key. Anyone who has the string can decode it, so it must never be used to protect a password or a secret.

The equals signs are padding. Base64 works in blocks of three bytes, and the padding fills out the final four-character group when the input length is not a multiple of three. One leftover byte produces ==, two leftover bytes produce a single =.

About one third larger, because every three bytes become four characters. The exact size is 4 × ceil(bytes ÷ 3), so small inputs can grow slightly more than a large file with a clean division.

The usual causes are missing padding, an extra prefix such as data:text/plain;base64,, characters that belong to the URL-safe alphabet, or line breaks inserted by an email client. Remove the prefix and try the - and _ variant if the string came from a JWT or a URL.

This page is built for text, so a decoded image will appear as unreadable characters. To rebuild a file, take the string after the comma in the data URI, decode it with a binary-aware tool and save the bytes with the matching extension.

No. Encoding and decoding happen in the page with the browser's own functions. Nothing is uploaded, logged or stored when you use the buttons.