Base64 Encoder Decoder - Encode and Decode Text Online
Base64 encoder decoder that turns text into a Base64 string and turns Base64 back into text, with standard or URL-safe alphabets and live round-trip output.
Base64 Encoder Decoder
Results
What Is Base64 Encoder Decoder?
A Base64 encoder decoder turns any string into a printable Base64 string and turns a Base64 string back into the original text, on the same page.
- • Embedding binary data in JSON or XML: Convert a small image, signature, or blob into a printable string that fits inside JSON or HTML data URIs.
- • Reading tokens and config strings: Decode the payload inside a JWT, API key, or Base64 config value.
- • Building URL-safe identifiers: Switch the alphabet to URL-safe so '+' and '/' are not percent-encoded in query strings.
- • Sanity-checking payloads: Encode a known string and decode it on the other side of a network call to confirm bytes did not get corrupted.
Base64 only uses printable ASCII characters, so the output travels cleanly through email headers, URL query strings, JSON values, and XML attributes.
The tool follows IETF RFC 4648, the current authoritative specification for Base16, Base32, and Base64 data encodings, so every result matches a production library. The URL-safe variant swaps '+' and '/' for '-' and '_' so the output can sit inside a URL or file name.
For developers who also need the numeric code points behind each character, the ASCII converter shows the same string as decimal, hex, octal, or binary codes.
How Base64 Encoder Decoder Works
The calculator reads the input one chunk at a time, looks up the matching alphabet character, and renders the result next to the live counts. Both directions share the same fields, so a round trip keeps the original text when the alphabet and padding choices match.
- mode: Encode turns text into a Base64 string. Decode turns a Base64 string back into text.
- alphabet: Standard uses '+' and '/'. URL-safe swaps them for '-' and '_'.
- padding: When on, '=' is appended so the encoded length is a multiple of 4. When off, trailing '=' is stripped. The decoder normalizes padding either way.
- inputText: Text used in Encode mode. UTF-8 encoded before the Base64 step.
- inputBase64: Base64 string used in Decode mode. Whitespace is stripped and trailing '=' is normalized; invalid characters cause an error naming the position.
The encoding step is the same regardless of alphabet choice; only the last two characters of the 64-character table change.
Encode 'Man' to 'TWFu'
Text = 'Man', Mode = Encode, Alphabet = Standard, Padding = On
1. UTF-8 encode 'Man' to [0x4D, 0x61, 0x6E] (24 bits). 2. Split into 6-bit groups: 010011, 010110, 000101, 101110. 3. Map each group through the alphabet to 19, 22, 5, 46. 4. Look up the alphabet characters: T, W, F, u.
Encoded output: TWFu. Base64 length: 4 characters. Input byte length: 3 bytes. Padding chars: 0.
This is the canonical example RFC 4648 uses to introduce the encoding.
Decode 'SGVsbG8sIFdvcmxkIQ==' back to 'Hello, World!'
Base64 = 'SGVsbG8sIFdvcmxkIQ==', Mode = Decode, Alphabet = Standard, Padding = On
1. Strip whitespace and validate every character. 2. Walk 4 characters at a time and reconstruct 3 bytes from the 6-bit values. 3. Drop trailing '=' so the byte count matches the original input. 4. UTF-8 decode the bytes back to text.
Decoded text: Hello, World!. Base64 length: 20 characters. Input byte length: 13 bytes. Padding chars: 2.
The two '=' tell the decoder that the last group only had one real byte.
According to IETF RFC 4648, Base64 encodes every 3 input bytes as 4 output characters using the A-Z, a-z, 0-9, '+', and '/' alphabet with '=' padding.
According to IETF RFC 4648, Section 10, the canonical Base64 of the ASCII string 'Man' is the 4-character string 'TWFu'.
If you need to convert Base64 output back to hex during a debug session, the binary to hexadecimal calculator handles the same byte stream through a different numeric base.
Key Concepts Explained
Four small ideas explain every result the calculator shows.
64-Character Alphabet
Base64 uses a fixed alphabet of 64 printable ASCII characters: A-Z, a-z, 0-9, '+', and '/'. Six bits map to one character, so every 3 input bytes become 4 output characters.
Padding to a Multiple of 4
When the input is not a multiple of 3 bytes, '=' is appended so the output length stays a multiple of 4. The decoder strips trailing '=' and re-pads, so padded and unpadded forms decode to the same bytes.
UTF-8 Byte Boundary
Encode starts by UTF-8 encoding the text, so non-ASCII characters such as 'é' use two to four bytes each. The Input Byte Length row shows the actual byte count.
URL-Safe Variant
RFC 4648 defines a URL-safe variant that swaps '+' for '-' and '/' for '_' so the output can sit inside a URL query string or file name.
Together: read the UTF-8 bytes, group them into 6-bit values, map each value through the alphabet, and pad to a multiple of 4.
When the encoded string is going to be stored as a file, the data storage converter can translate the encoded byte length into KB, MB, GB, or TB so the payload size lines up next to disk quotas.
How to Use This Calculator
Six short steps cover both Encode and Decode without any setup.
- 1 Pick the conversion mode: Use Encode to turn text into a Base64 string. Use Decode to turn a Base64 string back into text.
- 2 Choose the alphabet: Use Standard for almost every case. Switch to URL-safe when the output will live inside a URL or JWT token.
- 3 Pick a padding setting: Leave padding on for canonical RFC 4648 output. Switch off when the destination expects the stripped form.
- 4 Fill in the input field: Encode reads Text Input. Decode reads Base64 Input. The other field is ignored.
- 5 Read the result and counts: Base64 Output shows the encoded string in Encode mode. Decoded Text does the reverse.
- 6 Copy the result or fix the warning: The warning names the position of the first invalid character.
Paste Hello, World! into Text Input, leave Mode at Encode, Alphabet at Standard, and Padding on. The result panel shows SGVsbG8sIFdvcmxkIQ== with length 20, byte length 13, and padding count 2. Switch Mode to Decode and paste the same string into Base64 Input; the panel shows the original text.
For inspecting the bytes behind a decoded string, the text to binary converter turns the same text into a binary string.
Benefits of Using This Calculator
A purpose-built Base64 encoder decoder keeps the alphabet, padding, and live round trip in one place.
- • Bidirectional without switching pages: Encoding and decoding share the same fields and alphabet selector, which makes round-trip testing fast.
- • Both alphabets in one tool: Standard and URL-safe variants are one selector apart, so the same string can be re-encoded for a URL or JWT token.
- • Visible byte growth: Base64 length, input byte length, and padding count are shown next to the result.
- • Clear error messages: When the input contains an invalid character, the warning row names the character and its position.
For hex, decimal, binary, or octal values in a config or debug log, the hex calculator translates between those bases.
Factors That Affect Your Results
Three variables determine what the result looks like; three limitations tell you when a different tool is the right call.
Selected Alphabet
Standard and URL-safe Base64 produce different strings for the same input because the last two characters of the alphabet change.
Padding Setting
With padding on, the encoded output ends with '=' so the length is a multiple of 4. With padding off, trailing '=' is stripped. The decoder normalizes both forms.
Input Byte Length
Each 3 input bytes become 4 output characters, so the Base64 length is roughly 4/3 of the UTF-8 byte length.
- • Base64 is an encoding, not an encryption scheme. Anyone can decode the string back to the original text without a key.
- • The encoded string is about 33% larger than the underlying byte stream; not the right tool for shrinking data.
- • Decoding produces raw bytes; if those bytes are not valid UTF-8 text, the decoder surfaces a warning instead of returning replacement characters.
According to IETF RFC 4648, Section 5, the URL- and filename-safe Base64 variant replaces '+' and '/' with '-' and '_' so the output is safe inside URLs and file names.
If the decoded string contains non-ASCII characters, the Unicode text calculator shows the code points and UTF-8 byte view for the same input.
Frequently Asked Questions
Q: What does this tool do?
A: The tool turns text into a Base64 string and turns a Base64 string back into text. Encode reads a text input, UTF-8 encodes it, and writes the matching 6-bit alphabet characters; Decode reads a Base64 string and rebuilds the original bytes so the text comes back unchanged.
Q: How do you encode text to Base64?
A: Switch the mode to Encode, type or paste the text into the Text Input field, pick the standard or URL-safe alphabet, and read the Base64 string from the result panel. Each 3 input bytes become 4 output characters, so the Base64 length is roughly 4/3 of the UTF-8 byte length of the text.
Q: How do you decode a Base64 string back to text?
A: Switch the mode to Decode, paste the Base64 string into the Base64 Input field, match the alphabet the string was encoded with, and read the original text in the Decoded Text row. The decoder strips whitespace and normalizes trailing '=' padding, so both padded and unpadded input round-trips to the same text, and reports the position of the first invalid character when the string is malformed.
Q: What is the difference between standard and URL-safe Base64?
A: Standard Base64 uses '+' and '/' as the last two characters. URL-safe Base64 swaps them for '-' and '_' so the output can be pasted into a URL query string, a file name, or a JSON token without further escaping. The two alphabets decode the same way if the decoder is set to the matching variant.
Q: Why does Base64 output use '=' padding?
A: Base64 always writes 4 output characters for every 3 input bytes, so a partial final group is filled in with '=' so the encoded output length stays a multiple of 4. The decoder also normalizes missing '=' on the way in, so the Padding selector only controls what the encoder writes; both forms decode to the same text.
Q: Is Base64 the same as encryption?
A: No. Base64 is an encoding, not an encryption scheme: anyone can decode the string back to the original text without a key. Use it when you need to fit binary or non-ASCII bytes into a text-only channel (JSON, email, URLs, XML); use a real encryption scheme when the goal is to keep the content private.