← All tools
// Encoding

Base64 Encoder & Decoder online

Encode text or files to Base64, decode Base64 strings - runs in your browser

Base64 Encoder / Decoder logo
by
CHUNKY
MUNSTER
// Output
Output will appear here...
0
Input chars
0
Output chars
-
Size ratio

How to Use the Base64 Encoder / Decoder

  1. Paste text or a data string into the input field.
  2. Click Encode to convert to Base64, or Decode to recover original text from a Base64 string.
  3. For files, switch to File mode and drag a file to generate a data URI.
  4. Copy the output directly - no download required for text.

Base64 Encoder & Decoder handles the lingua franca for safely embedding binary data in text contexts: email attachments, JWT payloads, data URIs, API tokens, and cookie values all rely on it. This tool handles both text-to-Base64 and file-to-Base64 in one place, with support for URL-safe encoding and data URI generation - everything happens locally in your browser.

Text vs File Encoding

Text encoding converts your string's UTF-8 bytes to Base64. File encoding reads the file's raw bytes directly and produces a Base64 string or a complete data URI (data:image/png;base64,...) that can be embedded in HTML, CSS, or JSON. Data URIs let you include images and fonts in HTML without separate HTTP requests - useful for small assets but impractical for large ones due to the 33% size overhead.

Frequently Asked Questions

What is a Base64 data URI?

A data URI has the form data:[mediatype];base64,[encoded-data]. You can use it anywhere a URL is expected in HTML or CSS - for example as an img src or a CSS background-image. No separate network request is made.

Can I decode an image data URI back to a file?

Yes. Paste the data URI, click Decode, and download the resulting binary content as a file. The tool strips the data:...;base64, prefix before decoding.

What is the expansion factor of Base64?

Base64 produces roughly 4 characters for every 3 bytes of input - a 33% overhead. A 1 MB file becomes approximately 1.33 MB Base64.

Can I use Base64 to pass binary data in a JSON API?

Yes - JSON only supports strings, numbers, arrays, and objects. Binary data must be serialised as a Base64 string to be valid JSON. This is the standard approach for APIs that exchange binary blobs.

See also File to Base64, ASCII85, and the Base32 tool for encodings related to this Base64 Encoder & Decoder.

This Base64 Encoder & Decoder follows 📖 Reference: RFC 4648 - The Base16, Base32, and Base64 Data Encodings