Base64 Encoder and Decoder

Convert UTF-8 text to Base64 and back, switch alphabets, control padding, convert hex and inspect data URIs. Nothing leaves your browser.

Free · Instant · Private
Quick answer: Base64 represents binary data with 64 printable characters. Every 3 input bytes become 4 output characters, so the result is about 33.3% larger. The standard alphabet ends with + and /, while the URL-safe variant uses - and _. Paste your text below to encode it, or paste a Base64 string to decode it. Encoding is fully reversible and is not encryption.
Encode UTF-8 text to Base64
Accented letters, CJK characters and emoji are converted to UTF-8 bytes before encoding.
Encoded output
Decode Base64 to readable text
Whitespace and line breaks are ignored. Data URI prefixes are detected automatically.
Decoded output
Convert between hex and Base64
Useful for hashes, binary keys, byte arrays and certificate fingerprints.
Converted output
Inspect a data URI or Base64 payload
Detects the declared MIME type, decoded size, first bytes and common file signatures.
Inspection report
PropertyValue

Base64 quick-reference table

Canonical examples from RFC 4648 plus everyday strings. Each row is computed live by the same encoder used above.

Input textUTF-8 bytesStandard Base64Padding

What Is Base64 Encoding?

Base64 is a binary-to-text encoding scheme. It takes a sequence of arbitrary bytes and rewrites them using only 64 safe, printable ASCII characters. Because the output contains no control characters, no quotes and no non-ASCII bytes, it can be embedded in places that were designed for plain text: email bodies, JSON string values, XML attributes, HTML attributes, URL query parameters and configuration files.

The name comes from the size of the alphabet. Each output character carries exactly 6 bits of information because 2 to the power of 6 equals 64. A normal byte carries 8 bits, so the encoder groups input bytes into 24-bit triples and splits each triple into four 6-bit values. Those four values are then looked up in the alphabet table.

Base64 is defined by RFC 4648, which also standardises Base32 and Base16 (hex). It is a reversible transformation: decoding always returns the exact original bytes, and no key is involved. That is why it is classified as an encoding rather than a cipher.

The Base64 Alphabet and the Encoding Formula

Index 0 maps to uppercase A, index 25 maps to Z, index 26 maps to lowercase a, index 51 maps to z, index 52 maps to the digit 0, index 61 maps to 9, index 62 maps to plus, and index 63 maps to slash. The equals sign is reserved for padding and is not part of the 64-character alphabet.

Index rangeCharactersBit width
0 to 25A to Z6 bits each
26 to 51a to z6 bits each
52 to 610 to 96 bits each
62+ (- in Base64URL)6 bits
63/ (_ in Base64URL)6 bits
Padding only=Not data

The formula in plain arithmetic

For a triple of bytes b0, b1 and b2, the four output indices are:

  • i0 = b0 >> 2
  • i1 = ((b0 & 3) << 4) | (b1 >> 4)
  • i2 = ((b1 & 15) << 2) | (b2 >> 6)
  • i3 = b2 & 63

Decoding reverses the shifts and masks. The tool above applies these operations byte by byte to the UTF-8 representation of your input.

Padding rules

Input length is rarely an exact multiple of three bytes. If only one byte remains in the final group, the encoder emits two data characters followed by two equals signs. If two bytes remain, it emits three data characters followed by one equals sign. If the length is a multiple of three, no padding is added.

Remaining bytesData charactersPaddingExample inputExample output
34noneManTWFu
23=MaTWE=
12==MTQ==

Size Overhead and Line Wrapping

Three bytes become four characters, so the expansion factor is exactly 4/3, or a 33.3% increase before any line breaks. For n input bytes the padded output length is 4 x ceil(n / 3) characters. If the encoder inserts a newline every 76 characters, add roughly floor(length / 76) extra characters.

Input bytesBase64 charactersOverheadWith 76-character wrapping
14300.0%4
3433.3%4
91233.3%12
577633.3%76
608033.3%81
1024136833.6%1385

MIME email encoding, described in RFC 2045, wraps Base64 at 76 characters. PEM certificate blocks commonly use 64 characters. This tool lets you choose either width or no wrapping at all; the decoder ignores every whitespace character, so wrapped input still decodes correctly.

Standard Base64 vs. Base64URL vs. Base32

VariantCharacters 62 and 63PaddingTypical use
Standard Base64, RFC 4648 section 4+ and /Required, =Email, JSON, XML, data URIs
Base64URL, RFC 4648 section 5- and _Usually omittedURLs, JWT segments, cookies, file names
Base32, RFC 4648 section 6Uppercase letters and digits 2 to 7=Case-insensitive keys and TOTP secrets
Base16, RFC 4648 section 8Hex digits 0 to 9 and A to FNoneByte dumps, hashes, colour codes

The plus sign has a special meaning in URL query strings and the slash is a path separator, which is why the URL-safe alphabet substitutes them. Auto detect in this tool looks for a hyphen or underscore and switches alphabet accordingly.

Worked Examples

GoalInputResultWhy
Encode an ASCII wordManTWFuThree bytes map exactly to four characters with no padding.
Encode two bytesMaTWE=The final group holds two bytes, so one equals sign is added.
Encode one byteMTQ==The final group holds one byte, so two equals signs are added.
Decode a greetingSGVsbG8sIHdvcmxkIQ==Hello, world!Thirteen UTF-8 bytes decode back to thirteen ASCII characters.
Encode a non-ASCII lettercafe with an e acuteTwo UTF-8 bytes for the accented letterBase64 encodes bytes, so U+00E9 becomes C3 A9 before encoding.
Convert hex4d616eTWFuThe hex bytes 4D 61 6E are the ASCII letters M, a, n.

To verify any result, copy the encoded output into the Decode tab. A correct round trip returns the original text byte for byte. If the decoded bytes are not valid UTF-8, choose the hex view instead so you can inspect the raw values.

UTF-8 and Why Base64 Encodes Bytes, Not Characters

Base64 has no concept of letters, only bytes. A character such as an accented letter, a Chinese ideograph or an emoji is first converted to its UTF-8 byte sequence as specified in RFC 3629. A single visible character may therefore occupy two, three or four bytes, and each of those bytes contributes to the encoded length.

This is the most common source of confusion. Two Base64 strings that look identical may decode to different text if one was produced from UTF-8 bytes and the other from a legacy single-byte encoding. When decoding, this tool validates the byte stream strictly: overlong sequences, stray continuation bytes, surrogate code points and values above U+10FFFF are rejected with a clear message instead of producing replacement characters.

Data URIs and Everyday Uses

  • Data URIs, RFC 2397: a small image, font or file can be embedded as data:image/png;base64,.... The Inspector tab reports the declared MIME type, size and file signature.
  • Email attachments: MIME uses Base64 so that binary attachments survive transport through text-only mail relays.
  • APIs and JSON: binary fields, uploaded thumbnails and cryptographic nonces are usually carried as Base64 strings.
  • Web authentication: Basic authentication headers and the header and payload segments of JSON Web Tokens use Base64URL.
  • Configuration files: keys, certificates and encoded credentials are stored as single-line Base64 values in YAML, TOML and environment variables.

If you work with other encodings, the Morse Code Translator handles a classic character-level code, while the Number Base Converter shows how the same value looks in binary, octal, decimal and hex.

Common Mistakes

  1. Treating Base64 as encryption. It is trivially reversible and offers zero secrecy.
  2. Forgetting the UTF-8 step. Encoding a JavaScript string without converting it to bytes first corrupts any non-ASCII character.
  3. Mixing alphabets. A plus or slash in a URL-safe context, or a hyphen in a standard context, causes an invalid-character error.
  4. Removing padding incorrectly. Unpadded output is legal in many protocols, but the length must never be one more than a multiple of four.
  5. Confusing Base64 with hex. Hex uses 16 symbols and two characters per byte; Base64 uses 64 symbols and four characters per three bytes.
  6. Ignoring size growth. A 10 MB file becomes roughly 13.3 MB of text, which matters for payload limits and databases.
  7. Pasting HTML-escaped text. An ampersand written as an entity is not the same byte sequence as a plain ampersand.

Key Takeaways

  • Base64 maps 3 bytes to 4 printable characters and grows data by about 33.3%.
  • It is an encoding, not encryption, and requires no key to reverse.
  • Padding with equals signs only appears when the byte count is not a multiple of three.
  • Base64URL swaps plus and slash for hyphen and underscore so the result is safe in URLs.
  • Always convert text to UTF-8 bytes before encoding, and validate bytes before decoding to text.
  • Whitespace and line breaks are ignored by the decoder, so 76-character MIME wrapping is harmless.

Authoritative References

  • RFC 4648, The Base16, Base32, and Base64 Data Encodings.
  • RFC 2045, Multipurpose Internet Mail Extensions Part One, section 6.8 on Base64 Content-Transfer-Encoding.
  • RFC 3629, UTF-8, a transformation format of ISO 10646.
  • RFC 2397, The data URL scheme.
  • W3C File API and HTML specification notes on binary-to-text handling in browsers.

Last updated: December 5, 2026 · All conversions are performed locally in your browser. No data is stored or transmitted.

Base64 Encoder and Decoder FAQ

What is Base64 encoding used for?

Base64 converts binary bytes into a string of 64 printable ASCII characters so that data can travel safely through systems that only handle text, such as email headers, JSON documents and HTML attributes.

Is Base64 encryption?

No. Base64 is an encoding, not encryption. Anyone can reverse it without a key, so it provides no confidentiality and should never be used to protect passwords or secrets.

Why does Base64 make data larger?

Every three input bytes become four output characters, so the encoded text is about 33.3 percent larger than the original bytes before any line breaks are added.

What does the equals sign at the end of Base64 mean?

The equals sign is padding. It is added when the input byte count is not a multiple of three: one equals sign means two bytes in the final group, and two equals signs mean one byte in the final group.

What is the difference between standard Base64 and Base64URL?

Base64URL replaces the plus sign with a hyphen and the slash with an underscore, and usually omits padding, so the result is safe inside URLs, cookies and file names. The encoding algorithm is otherwise identical.

How do I decode Base64 text that contains non-English characters?

Encode the text as UTF-8 bytes first, then decode those bytes as Base64. This tool performs the UTF-8 conversion for you and reports an error when the bytes are not valid UTF-8.

Why does my Base64 string fail to decode?

Common causes are an invalid character, a length that is one more than a multiple of four, misplaced padding, or confusing standard Base64 with Base64URL. Switch the alphabet option or remove stray characters and try again.

Is my data uploaded when I use this tool?

No. All encoding and decoding runs locally in your browser with JavaScript. Nothing is sent to a server, stored, or logged.