What is Base64
Base64 encodes binary data into 64 ASCII characters (A-Z, a-z, 0-9, +, /, = padding). It was designed
to move binary data through text-only systems like email (SMTP) and JSON APIs. The output is about 33%
larger than the input because every group of 3 bytes is translated into 4 printable
characters.1
How the 6-bit encoding works
The encoding treats the input as a stream of bytes, groups them into 24-bit sets of three octets, and then splits each set into four 6-bit values; each value becomes one character from a fixed 64-entry alphabet, so the output length is always a multiple of four characters unless the caller explicitly omits the padding.2
A short string shows the ratio directly. Encoding the text hello produces
aGVsbG8=, five bytes turned into eight Base64 characters including the trailing padding
character. Pasting that same string back into Decode mode returns hello exactly, which is
the easiest way to confirm the round trip is lossless before trusting the tool with a larger payload.
Base64 is encoding, not encryption. Anyone can decode it with no key. It is commonly used for data
URIs (data:image/png;base64,...), embedding certificates in PEM files, and passing binary
blobs through JSON APIs that only accept strings. The equal sign padding ensures the length is always
a multiple of 4. RFC 4648 recommends that decoders reject data containing characters outside the
alphabet, but some specifications instead ignore those characters, so different tools can disagree on
whether a given string is valid.2
Why decode or encode offline?
Online Base64 tools require you to paste text or upload files to a remote server. For JWT tokens, private keys, or internal config blobs, that is a security violation. The moment your data reaches a third-party server, you have lost control of it regardless of what the privacy policy claims.
CapyToolkit processes everything in your browser tab using native btoa() and
atob(), so the conversion never touches the network.3 Disconnect from
the internet after loading the page and the tool keeps working for text, files, and data URIs. If
you handle production secrets, authentication tokens, or customer records, keeping the data inside the
tab removes whole classes of accidental exposure that no privacy policy can fully prevent.
TIP You can disconnect from the internet after the page loads and the tool keeps working because every encode and decode runs through native browser APIs that need no socket, no remote endpoint, and no round trip, so the bytes you paste or drop never travel beyond your own machine.
Encoding vs decoding
In encode mode, the tool converts your text to UTF-8 bytes first (using the browser's TextEncoder),
then transforms those bytes to Base64 with btoa(). This two-step process is necessary
because btoa() only handles Latin-1 characters natively.3 The UTF-8 step ensures Chinese,
Arabic, Emoji, and other non-ASCII text encodes correctly.4
In decode mode, the tool strips whitespace and validates the Base64 string against the character set
(/^[A-Za-z0-9+/]*={0,2}$/), then converts the decoded binary bytes with TextDecoder to
reconstruct the original string.4 Invalid characters or malformed padding produce a clear error
rather than garbled output, so you notice the mistake immediately instead of debugging a subtly wrong
value.1
Why the UTF-8 step comes first
btoa() interprets each input character as a single byte and throws a "character out of
range" exception as soon as it meets a code point above 255, which is why raw emoji or Chinese text
fails unless you first convert the string to its UTF-8 byte representation with
TextEncoder. The reverse happens on decode, where the raw bytes are handed to TextDecoder so the original
multi-byte characters come back intact instead of appearing as mojibake.
File encoding support
Any file up to 500 MB can be encoded. The tool reads the file with
FileReader.readAsDataURL(), then strips the data:*/*;base64, prefix to give
you clean Base64 output.5 This is useful for generating data URIs for
images, embedding fonts in CSS, attaching PDFs as data URLs in HTML emails, or transporting binary data
through text-only APIs that would otherwise reject raw bytes.
Handling large outputs
Because Base64 output can be very long (a 5 MB file produces roughly 6.7 MB of Base64), the tool
provides a Download as .txt button. This creates a Blob and object URL so you can save the output
without crashing the browser by trying to render megabytes of text in a textarea, and the file is
written directly from the in-memory result without a second round trip through the page.
NOTE
Base64 expands data by about 33% because every 3 input bytes become 4 output characters, so a 10 MB
file produces roughly 13.3 MB of Base64. For multi-hundred-megabyte uploads, keep an eye on the
browser's available memory because the decoded bytes, the encoded string, and the Blob can all be
resident at the same time.
Base64 URL encoding and application contexts
Standard Base64 uses the characters A-Z, a-z, 0-9, plus sign (+), and forward slash (/), with equals
signs (=) for padding. Two of these characters are not safe in URLs because browsers interpret + as a
space and / as a path separator.6 Base64 URL encoding replaces + with a hyphen (-) and / with an
underscore (_), making the output safe to embed in URL paths and query strings without percent-encoding.
Padding is often omitted entirely in URL-encoded contexts because the equals sign requires encoding in
query strings and the length can be inferred from the string length. JWTs use Base64 URL without
padding for exactly this reason: all three parts of a JWT are Base64 URL-encoded so the token can be
placed directly in an Authorization header or URL parameter.7
JWT access tokens and PKCE code verifiers and challenges use Base64 URL encoding.78 When debugging an OAuth flow, you may encounter tokens in standard
Base64 (with + and /), Base64 URL (with - and _), or Base64 URL without padding, and distinguishing
between them is the first step before decoding. This tool handles standard Base64 and UTF-8 text. If
you encounter a Base64 URL string, substitute hyphens back to plus signs and underscores back to
forward slashes, then add the correct padding equals signs to make the length a multiple of four before
pasting. Alternatively, paste the raw JWT into the separate JWT decoder, which handles Base64 URL
format natively without any manual substitution.
Base64 Text & File Encoder/Decoder Reference
- Size expansion ~33% larger than input
- Max file size 500 MB
Encode or decode your own text or file above and compare the output size against this ratio.
- 1.
S. Josefsson, "The Base16, Base32, and Base64 Data Encodings," RFC 4648, IETF, October 2006. https://www.rfc-editor.org/rfc/rfc4648
- 2.
"Base64," en.wikipedia.org, accessed June 2026. https://en.wikipedia.org/wiki/Base64
- 3.
Mozilla Developer Network, "Window: btoa() method," developer.mozilla.org, June 2025. https://developer.mozilla.org/en-US/docs/Web/API/Window/btoa
- 4.
F. Yergeau, "UTF-8, a transformation format of ISO 10646," RFC 3629, IETF, November 2003. https://www.rfc-editor.org/rfc/rfc3629
- 5.
Mozilla Developer Network, "FileReader: readAsDataURL() method," developer.mozilla.org, September 2025. https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL
- 6.
WHATWG, "URL Standard," url.spec.whatwg.org, June 2026. https://url.spec.whatwg.org/
- 7.
M. Jones, J. Bradley, and N. Sakimura, "JSON Web Token (JWT)," RFC 7519, IETF, May 2015. https://datatracker.ietf.org/doc/html/rfc7519
- 8.
N. Sakimura, J. Bradley, and N. Agarwal, "Proof Key for Code Exchange by OAuth Public Clients," RFC 7636, IETF, September 2015. https://datatracker.ietf.org/doc/html/rfc7636