Base64 Text & File Encoder/Decoder

Encode text or files to Base64, or decode Base64 back to text. Nothing leaves your browser.

ZERO UPLOAD · ALL LOCAL

What to look for

  • 33% larger than the original binary
  • 32 KB
  • up to 2 MB
  • 4,096 bytes (assetsInlineLimit)

A wrong or mismatched media type prefix produces a silently broken resource, with no console error to explain it.

What this page covers

  • Alphabet substitution replace - with + and _ with / before using a standard Base64 decoder
  • Padding restoration append = characters until the string length is a multiple of 4
  • Payload location split the token on '.' and take index [1]
  • Never use alg: none it tells the verifier to skip signature checking entirely, accepting forged claims

What to look for

  • 76 characters per line, with CRLF endings (RFC 2045)
  • about 33%, plus ~2.6% more for MIME's CRLF wrapping
  • 25 MB total per message
  • 35 MB per message

LF-only line endings (common from Unix tools) can pass local validation but fail silently on a strict relay that enforces the CRLF requirement.

What this page covers

  • Linux single-line encode base64 -w 0 cert.pem, since GNU base64 wraps by default
  • macOS single-line encode base64 cert.pem, since macOS base64 does not wrap by default
  • Portable newline strip pipe through tr -d '\n' when -w isn't available (BSD base64 lacks it)
  • Cleanup pattern trap 'rm -f /tmp/cert.pem' EXIT ensures a decoded temp file is removed even on script failure

What to look for

  • 33% larger than the raw binary
  • 10 MB
  • 6 MB
  • under 100 KB; use multipart or a pre-signed URL above that

A JSON parser buffers the entire document in memory before exposing any field, so a 10 MB image forces 13.3 MB of Base64 JSON into memory before decoding even starts.

What to look for

  • 64 characters per line (not MIME's 76)
  • roughly 1,700 bytes of Base64 across about 27 lines
  • exactly 5 hyphens on each side

A PEM wrapped at 76 characters instead of 64 fails OpenSSL parsing with a generic error, not a message pointing at the line width.

What to look for

  • 64 printable characters, each carrying 6 bits
  • exactly 33% (3 input bytes become 4 output characters)
  • under 10ms to encode/decode inputs under 10 MB on typical hardware

Base64 is encoding, not encryption: anyone can decode it instantly with no key required.

What to look for

  • A-Z (0-25), a-z (26-51), 0-9 (52-61), - (62), _ (63)
  • 32 random bytes encode to a 43-character Base64url string
  • usually stripped (JWT, PKCE, WebAuthn), but not universal (GCS signed URLs keep it)

Only two alphabet characters differ from standard Base64 (+/- and //_), so converting between the two variants is a text substitution, not a re-encode.

What this page covers

  • Python base64.b64decode() adds missing padding automatically
  • Go base64.StdEncoding errors on unpadded input; base64.RawStdEncoding accepts it
  • Java Base64.getDecoder() accepts both padded and unpadded input
  • JavaScript atob() requires padded input and throws DOMException otherwise

What to look for

  • 44 Base64 characters vs 64 hex characters
  • ~133 KB as Base64 vs ~200 KB as hex
  • 40 hex characters (SHA-1, 20 bytes) - always hex, never Base64

Comparing a Base64-encoded value against a hex-encoded value of the same bytes always mismatches as text, even though the underlying data is identical.

What to look for

  • data:[<mediatype>][;base64],<data>
  • 32 KB
  • up to 2 MB
  • 15-25% shorter than Base64 for SVGs under 1 KB

Data URIs are not cached independently; the inline data re-downloads with every page that includes it, unlike an external resource.

Input (Text)
Input (File)

Drop a file here

or click to select a file · any format · max 500 MB

Output (Base64 or Text)

  1. Select DECODE (default) to paste Base64 and get the original text, or switch to ENCODE to convert text to Base64.
  2. For text: type or paste into the text area — the result appears instantly.
  3. For files: drop a file onto the drop zone or click it to browse — any file up to 500 MB works.
  4. Use Copy to grab the output, or Download as .txt to save long Base64 strings.
  5. Note: Base64 is encoding, not encryption. Anyone can decode it with no key.

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

Base64 tool in Encode mode turning the text Hello, CapyToolkit! with a check mark into a Base64 string
Encoding "Hello, CapyToolkit! ✓" gives SGVsbG8sIENhcHlUb29sa2l0ISDinJM=. The text is 23 UTF-8 bytes because the check mark alone takes three, and 23 bytes leave one = of padding at the end.

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.

Everything described so far is the browser's own toolchain: btoa(), atob(), and TextEncoder. Outside the browser, every major language handles Base64 through its own libraries under a different function name, which is why half-remembered names like Python's encodebytes or Ruby's encode64() feel familiar yet refuse to resolve when you type them into the wrong environment: each name belongs to one language's library. The encoding itself is one standard, so a Base64 string produced here decodes identically in any of them. Only the call site changes, and your language's own documentation is the authority on the exact function name.

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

  • ~33% larger than input
  • 500 MB

Encode or decode your own text or file above and compare the output size against this ratio.

Sources
  1. 1.

    S. Josefsson, "The Base16, Base32, and Base64 Data Encodings," RFC 4648, IETF, October 2006. https://www.rfc-editor.org/rfc/rfc4648

  2. 2.

    "Base64," en.wikipedia.org, accessed June 2026. https://en.wikipedia.org/wiki/Base64

  3. 3.

    Mozilla Developer Network, "Window: btoa() method," developer.mozilla.org, June 2025. https://developer.mozilla.org/en-US/docs/Web/API/Window/btoa

  4. 4.

    F. Yergeau, "UTF-8, a transformation format of ISO 10646," RFC 3629, IETF, November 2003. https://www.rfc-editor.org/rfc/rfc3629

  5. 5.

    Mozilla Developer Network, "FileReader: readAsDataURL() method," developer.mozilla.org, September 2025. https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL

  6. 6.

    WHATWG, "URL Standard," url.spec.whatwg.org, June 2026. https://url.spec.whatwg.org/

  7. 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. 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

FAQ

Yes. CapyToolkit does not collect, transmit, or store any text or file you Base64 encode or decode here. All encoding and decoding happens in your browser using btoa() and atob(). Disconnect from the internet after loading the page and it will still work.

Encoding is a reversible transformation that anyone can undo with no key. Base64 has no secret component. Encryption requires a key to reverse. Never use Base64 to protect sensitive data. It only changes the representation so binary data can travel through text-only systems like JSON or email.

The tool uses TextEncoder and TextDecoder to handle UTF-8 correctly. If you see mojibake, the input was likely encoded with a different character set, or the Base64 was generated without proper Unicode handling. Try re-encoding with this tool to get a correct UTF-8 Base64 string.

Any file up to 500 MB. The tool reads the file using the FileReader API and outputs a Base64 string. You can download the result as a .txt file. This is useful for generating data URIs or embedding binary data in JSON configs.

Base64 expands data by about 33%. Every 3 bytes of input become 4 characters of Base64 output, plus optional padding (=). This overhead is normal and expected. It is the trade-off for representing binary data with only printable ASCII characters.

Yes. Once the page loads, no internet connection is needed. The entire tool runs client-side.

Additional resources

Guides

Embedding Images as Data URIs in HTML and CSS Learn how to embed images, SVGs, and fonts as Base64 data URIs in HTML attributes and CSS. Includes format, size limits, and when to avoid inlining. Building HTTP Basic Auth Headers with Base64 HTTP Basic Authentication encodes username:password in Base64 for the Authorization header. Learn the format, curl usage, and why HTTPS is required. How JWT Tokens Use Base64url Encoding JWT tokens encode header and payload as Base64url without padding. Learn the structure, how to decode the claims, and why JWTs are not encrypted by default. Base64 in Kubernetes Secrets Kubernetes Secrets store values as Base64-encoded strings in YAML. Learn how to encode, decode, and manage secrets , and why Base64 is not encryption. MIME Email Attachments and Base64 Encoding SMTP email encodes attachments as Base64 in MIME multipart messages. Learn the format, line length rules, charset headers, and common email encoding bugs. Storing Binary Secrets in Environment Variables Environment variables only hold text strings, but Base64 encoding lets you store binary secrets like TLS keys and certificates as env var values. Learn the pattern and risks. Embedding Binary Data in JSON APIs JSON cannot represent raw binary data. Base64 encoding is the standard way to embed images, files, and binary fields in JSON API requests and responses. URL-Safe Base64 vs Standard Base64 URL-safe Base64 replaces + with - and / with _ so strings are safe in URLs, HTTP headers, and filenames. Learn when to use each variant and how to convert between them. SSH Keys and PEM Certificates in Base64 SSH keys, TLS certificates, and PEM files wrap raw binary keys in Base64 between header and footer markers. Learn the format, how to decode keys, and common CI/CD patterns.