Base64 encoding, byte-exact and UTF-8 safe
Base64 is a binary-to-text encoding that packs every three input bytes into four printable ASCII characters. The output uses the standard alphabet A-Z, a-z, 0-9, plus + and /, with = padding when the input length leaves one or two bytes over. Encoded output is roughly 33% longer than the input, so a 300-byte string becomes about 400 characters of base64.
TextResult runs the encode through btoa(unescape(encodeURIComponent(s))), which first widens any non-ASCII codepoints into UTF-8 bytes, then base64-encodes the byte stream. So café encodes the four bytes 63 61 66 C3 A9, not five 16-bit code units. Pure ASCII input gets the same result as a server-side base64 command.
Toggle Wrap Lines in the action bar to split the output every Line Length characters (default 76, the MIME limit from RFC 2045). Leave it off for a single-line token suitable for HTTP headers, data URIs, or JSON values. This is encoding, not encryption: anyone can decode base64. For a one-way digest, see SHA-256.
How to use base64 encode text
- 1Paste or type your text into the input panel on the left.
- 2The base64 result appears in the output panel on the right as you type.
- 3Toggle Wrap Lines in the action bar if you need MIME-style line breaks.
- 4Adjust Line Length (4-998) to match the format you are targeting.
- 5Click Copy in the output header to copy the encoded string.
Keyboard shortcuts
Drive TextResult without touching the mouse.
| Shortcut | Action |
|---|---|
| Ctrl F | Open the find & replace panel inside the input Plus |
| Ctrl Z | Undo the last input change |
| Ctrl Shift Z | Redo |
| Ctrl Shift Enter | Toggle fullscreen focus on the editor Plus |
| Esc | Close find & replace, or exit fullscreen |
| Ctrl K | Open the command palette to jump to any tool Plus |
| Ctrl S | Save current workflow draft Plus |
| Ctrl P | Run a saved workflow Plus |
What this tool actually does
Standard RFC 4648 alphabet with padding
Output uses A-Z a-z 0-9 + / with = padding. Length grows by roughly 4/3. A 1-byte input produces 2 chars + ==, a 2-byte input produces 3 chars + =, and a 3-byte input produces 4 chars with no padding.
UTF-8 widening for non-ASCII text
Before encoding, the string is converted to UTF-8 bytes via encodeURIComponent. café becomes the bytes 63 61 66 C3 A9, then base64s to Y2Fmw6k=. This matches the output of printf "café" | base64 on Linux/macOS.
Optional MIME line wrapping
Turn on the Wrap Lines toggle to split the output every Line Length characters with \n separators. Default is 76 (RFC 2045 MIME limit). The trailing newline is trimmed. Off by default, so the result is one continuous line.
Configurable line length, 4 to 998
When wrapping is on, Line Length accepts any integer from 4 to 998. Common values are 64 (PEM), 76 (MIME), and 998 (the SMTP line-length cap). Values below 4 round up internally.
Browser-side, no upload
Encoding runs through the native btoa on each keystroke. No server round-trip, no log of what you pasted. Safe for tokens, API keys, and any text you would not want leaving the page.
Worked example
The newline encodes as 0x0A and the é becomes the UTF-8 bytes C3 A9, so the byte sequence is 18 bytes long and ends with two = pads.
Hello, world! Café
SGVsbG8sIHdvcmxkIQpDYWbDqQ==
Settings reference
| Behaviour | Effect on output |
|---|---|
| ASCII letters and digits | Encoded as their UTF-8 byte values into the standard A-Z a-z 0-9 + / alphabet. |
| Non-ASCII characters | Widened to UTF-8 bytes first. é -> C3 A9 -> w6k. |
| Output length | Roughly 4/3 of the input byte length, rounded up to a multiple of 4. Padding = fills the last group. |
| URL-safe | Off by default (standard alphabet + / =). On replaces + with -, / with _, drops trailing = padding (RFC 4648 base64url). Required for JWT tokens and most modern web APIs. |
| Wrap Lines | Off by default (single line). On splits the output every Line Length characters with \n. |
| Line Length | Default 76 (MIME). Range 4 to 998. Only takes effect when Wrap Lines is on. |
| Whitespace and line breaks | Encoded as their literal byte values (0x20, 0x0A, 0x09). Not stripped. |
| Empty input | Returns an empty string. |
FAQ
Is base64 encryption?
Why is the output longer than the input?
Does it handle accented characters and emoji?
encodeURIComponent. café encodes the bytes C3 A9 for the é, and a single emoji like 🙂 encodes 4 UTF-8 bytes.Should I turn on line wrapping?
Is the output sent anywhere?
btoa function. Nothing is uploaded, nothing is logged.