Upload a file
  1. base64hub
  2. Text tools
  3. ASCII to Base64

ASCII to Base64: Encode Plain 7-Bit Text

Encode text using the 7-bit ASCII character set. Characters outside ASCII are replaced with ? and counted, so you know immediately if your input is not as plain as it looks.

Free no sign-up, no limits Local nothing uploaded 0–127 only, others flagged Updated Oct 27, 2026
Input 0 BOutput 0 BSize –

Processed in your browser. This page cannot send your data anywhere – how we know

How to encode ASCII text to Base64

  1. Type or paste the text into Input · text. Charset is preset to ASCII.
  2. The Base64 appears in Output · Base64. If the text contains characters outside ASCII, a warning under the tool says how many were replaced with ?.
  3. Remove or replace those characters, or switch Charset to UTF-8 if the receiver understands it.
  4. Copy the result or download it as base64.txt.

The reverse is Base64 to ASCII.

What counts as ASCII

ASCII defines 128 codes, 0 to 127, one byte each with the top bit clear. Codes 32 to 126 are the printable characters: the space, digits, the English letters and common punctuation. Codes 0 to 31 and 127 are control characters such as tab (9), line feed (10) and carriage return (13).

Anything else, including é, ß, €, curly quotes, non-breaking spaces and emoji, is not ASCII. Text pasted from word processors and web pages often carries them unnoticed, typically as typographic quotes and dashes, and the replacement warning catches them.

Examples

TextBase64Note
Hello, ASCII!SGVsbG8sIEFTQ0lJIQ==Same as UTF-8
200 OKMjAwIE9L6 bytes, no padding
{}[]<>e31bXTw+Punctuation is ordinary bytes
a, tab, bYQliTab is byte 09
line1 CR LF line2bGluZTENCmxpbmUy0D 0A in the middle
user:passdXNlcjpwYXNzHTTP Basic auth credentials
GrüßeR3I/P2U=2 characters replaced with ?
naïve cafébmE/dmUgY2FmPw==2 characters replaced with ?

Encoding every character as one byte also makes the size easy to predict: n characters give 4 × ⌈n / 3⌉ Base64 characters.

Why ASCII and Base64 belong together

Base64 was designed for channels that only carried 7-bit ASCII safely. Early email (SMTP) is the classic example: bytes above 127 could be stripped or altered on the way, so binary attachments and non-English text were encoded into a subset of ASCII that every system handled. That is still the reason Base64 exists, and it explains its alphabet: 64 characters that are printable, identical in every ASCII-derived charset and, apart from + and /, free of characters with a special meaning in common formats. How Base64 works goes through the mechanics.

Some systems still expect ASCII only, for example legacy interfaces and HTTP header values, where non-ASCII handling varies between servers. Encoding with the ASCII charset here confirms that the input is safe for them before it goes anywhere. For the Authorization header specifically, the Basic Auth header generator builds the full Basic dXNlcjpwYXNz value.

ASCII to Base64 in code

Python refuses non-ASCII characters by default, which is a useful check:

import base64

base64.b64encode("200 OK".encode("ascii")).decode()   # 'MjAwIE9L'
"Grüße".encode("ascii")
# UnicodeEncodeError: 'ascii' codec can't encode characters in position 2-3
"Grüße".encode("ascii", errors="replace")              # b'Gr??e', like this tool

In JavaScript, btoa() accepts every character up to code 255, so it will not catch Latin-1 letters like ü. Test the string first with /^[\x00-\x7F]*$/.test(s) if it must be pure ASCII. More on the Python and JavaScript pages.

FAQ

Is ASCII to Base64 different from UTF-8 to Base64?

Not for pure ASCII text. UTF-8 was designed so that the first 128 characters keep their ASCII byte values, so Hello, ASCII! gives SGVsbG8sIEFTQ0lJIQ== in both. They differ only when the text contains other characters.

What happens to characters like ü or emoji?

ASCII has no code for them, so each becomes ? (byte 3F) and the tool reports how many were replaced. Grüße encodes as R3I/P2U=, which decodes to Gr??e.

Is Base64 output itself ASCII?

Yes. All 65 characters Base64 uses (A–Z, a–z, 0–9, +, / and =) are printable ASCII, which is why Base64 passes through systems that only handle 7-bit text.

Can control characters like tabs and newlines be encoded?

Yes. They are ASCII too (codes 0–31) and encode like any other byte: a, tab, b gives YQli.