Developer Tools100% Client-Side
All Tools

Base64 Encoder & Decoder

Convert text, strings, or image files to Base64 and decode Base64 back to plain text or preview images with full UTF-8 and Khmer script support.

Base64 Output

About & How It Works

Technical calculation logic, standards, and operational details

The Base64 Encoder & Decoder is a privacy-first, client-side tool for converting plain text, UTF-8 strings (including full Unicode and Khmer script), and binary file content (images, PDFs) into their Base64 ASCII representation and back. Base64 encoding (defined in RFC 4648) is a binary-to-text encoding scheme that represents binary data using 64 printable ASCII characters (Aโ€“Z, aโ€“z, 0โ€“9, +, /), making it safe to embed binary payloads inside text-only channels such as JSON request bodies, XML documents, CSS data URIs, and email MIME attachments. This tool handles the full UTF-8 byte encoding pipeline required for non-ASCII characters, a step that many competing online encoders incorrectly omit, producing garbled output for Khmer, Chinese, or Arabic input.

Algorithmic Logic & Calculation

For text encoding, the tool first encodes the input string as a UTF-8 byte array using TextEncoder, then converts each byte to a binary string with String.fromCharCode(), and finally applies btoa() to generate the Base64 output. This three-stage pipeline ensures Khmer characters (multi-byte in UTF-8) are correctly represented. For decoding, atob() reverses the Base64 to a binary string, Uint8Array captures each byte code, and TextDecoder reconstructs the original UTF-8 string. For image/file encoding, the FileReader API reads the file as a DataURL, which is natively Base64-encoded.

Technical Standards & Compliance

Implements RFC 4648 (The Base16, Base32, and Base64 Data Encodings) standard encoding and URL-safe variant (ยง5). UTF-8 encoding follows Unicode Standard 15.0.

Key Features & Capabilities

Full UTF-8 & Khmer Script Support

Correctly handles multi-byte Khmer, Chinese, Arabic, and emoji characters using TextEncoder/TextDecoder pipeline.

Image & File to Base64 Data URI

Drag-and-drop or browse to encode any image (PNG, JPG, GIF, SVG) into a CSS/HTML-ready Base64 data URL.

URL-Safe Base64 Variant

Optionally outputs URL-safe Base64 (RFC 4648 ยง5), replacing + with - and / with _ for safe embedding in URLs.

Decoded Image Preview

When decoding a Base64 image string, the tool renders a live visual preview of the decoded image inline.

Practical Real-World Use Cases

Embedding Images in CSS & HTML

Frontend developers embed small icon SVGs or loading spinners as Base64 data URIs to eliminate HTTP image requests.

API Payload & JSON Encoding

Backend engineers encode binary file attachments as Base64 before including them in JSON API request bodies or webhook payloads.

Email MIME Attachment Debugging

Email developers decode Base64-encoded MIME attachment blocks from raw .eml files to inspect attached documents.

How to Use

  1. Select "Text" or "File/Image" mode.
  2. Choose Encode or Decode.
  3. Input text or drop an image to get instant output.
In-Depth Educational Guide

Client-Side Security Guide: Why In-Browser Tools Protect Your Sensitive Data

Learn how modern WebAssembly and JavaScript enable private, 100% in-browser utilities that guarantee zero data leakage, ideal for API keys, JSON payloads, and sensitive tokens.

Read Full Guide

Frequently Asked Questions

Yes, UTF-8 byte encoding is fully implemented so Khmer vowels and sub-scripts are never garbled.

Related Developer Tools

View all โ†’