Skip to content

Base64

Encode and decode Base64 strings instantly. Supports text and binary data.

Part of Dev Utils · Built by Sandeep Upadhyay

  • Base64 encode and decode
  • Text and binary support
  • One-click copy to clipboard

When to use Base64

  • Embedding images in CSS or HTML: Convert small icons or favicons to Base64 data URIs to eliminate a network request, inlining the image directly in the stylesheet or HTML.
  • Inspecting JWT token payloads: Decode the middle segment of a JWT to read the claims object without a separate JWT debugging tool - paste the segment and decode as URL-safe Base64.
  • Testing API authentication headers: Encode Basic Auth credentials (username:password) to Base64 for manual API testing in curl or a REST client like Insomnia.
  • Encoding binary data for JSON payloads: Convert file contents to Base64 before embedding in a JSON request body when the API expects binary data as a Base64 string field.

How Base64 encoding transforms binary data into safe text

Base64 is a binary-to-text encoding scheme defined in RFC 4648 that represents arbitrary binary data using only 64 printable ASCII characters: A-Z, a-z, 0-9, plus (+), and forward slash (/), with equals signs (=) used as padding. The encoding works by taking every three bytes of input data (24 bits), splitting them into four groups of 6 bits, and mapping each 6-bit value to one of the 64 characters in the Base64 alphabet. Because every possible 6-bit value (0-63) maps to a printable character, the output can be safely transmitted through systems that only handle text - email, URLs, JSON payloads, and HTML attributes.

The tool encodes strings using btoa() (binary to ASCII) and decodes using atob() (ASCII to binary), both of which are built into every modern browser. For Unicode text, the input is first encoded to UTF-8 bytes using TextEncoder before Base64 encoding, which handles characters outside the ASCII range correctly. For file encoding, the File API reads the file as an ArrayBuffer, which is then converted to a Base64 string suitable for use in a data URI.

The URL-safe Base64 variant (defined in RFC 4648 Section 5) replaces + with - and / with _ to avoid conflicts with URL reserved characters. The tool supports switching between standard and URL-safe alphabets. A common use case for the URL-safe variant is JSON Web Tokens (JWT): the three dot-separated segments of a JWT are URL-safe Base64-encoded JSON objects.

Try Base64

Interactive Base64 - coming soon