Skip to main content

Free Base64 Encoder & Decoder

Encode text or files to Base64, or decode Base64 strings back to plain text. Instant, private, and free.

Works offline once loaded
Alphabet

Not encryption. Base64 is an encoding scheme β€” anyone who sees the output can instantly decode it. It provides no confidentiality or security.

Common uses

  • Encode API Data in Base64Encode credentials, tokens, and payloads to Base64 for use in HTTP headers and API requests.
  • Encode Images to Base64 for CSSConvert small images and icons to Base64 data URLs for embedding directly in CSS or HTML.
  • Encode Files to Base64 for EmailEncode file attachments to Base64 for MIME email construction or debugging email API payloads.
  • Decode and Inspect JWT TokensDecode the header and payload sections of a JSON Web Token (JWT) to inspect its claims.
  • Encode Binary Data for Text TransferEncode files or binary data to Base64 so they can be safely included in JSON, XML, or plain text.

How It Works

Base64 encoding and decoding here runs entirely in your browser using JavaScript's built-in btoa/atob functions and the FileReader API β€” no server, no upload, no third-party library. For text, a encodeURIComponent/unescape wrapper ensures Unicode characters encode correctly; for files, FileReader.readAsDataURL() produces the Base64 data directly.

  1. 1
    Text input: UTF-8 normalization
    Raw text is piped through encodeURIComponent then unescape before being handed to btoa. This two-step converts multi-byte Unicode characters (emoji, accented letters, non-Latin scripts) into a byte sequence that btoa can safely encode β€” skipping this step would throw a 'character out of range' error for anything outside Latin-1.
  2. 2
    File input: FileReader API
    When you select a file, the browser's FileReader.readAsDataURL() method reads the file locally and returns a data URL in the form data:<mime>;base64,<payload>. The tool strips the prefix and keeps only the raw Base64 payload, supporting any file type up to 20 MB.
  3. 3
    URL-safe variant (RFC 4648 Β§5)
    Switching to URL-safe mode applies three character substitutions to the standard output: + becomes -, / becomes _, and trailing = padding is removed. This matches the RFC 4648 Β§5 alphabet used in JWTs, URL parameters, and filenames where + and / would need percent-encoding.
  4. 4
    Decoding: padding restoration and atob
    On decode, the tool strips whitespace (handling MIME-wrapped Base64), maps the URL-safe alphabet back to standard characters, then re-adds any missing = padding before calling atob. The output bytes are converted back to a Unicode string with decodeURIComponent(escape(...)) β€” the mirror of the encode path.

All encoding and decoding happens locally in your browser β€” the text you type and any file you select are never sent to a server.

Related Tools

Frequently Asked Questions