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.
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.
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
- Select "Text" or "File/Image" mode.
- Choose Encode or Decode.
- Input text or drop an image to get instant output.
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.
Frequently Asked Questions
Related Developer Tools
View all โJSON Formatter & Validator
Prettify, minify, validate, and format JSON code with syntax diagnostics.
UUID / GUID Generator
Generate cryptographically random UUID v4 strings in bulk with custom casing.
JWT (JSON Web Token) Decoder
Decode JSON Web Tokens instantly to inspect header, payload, and expiry.
