CodePersia

Base64 Encoder & Decoder Online — Text, Files & Images

Tool processing happens entirely in your browser. Your input is never sent to our servers.

Output will appear here...

What is Base64 Encoding?

Base64 is a binary-to-text encoding scheme that represents binary data using a set of 64 ASCII characters (A-Z, a-z, 0-9, +, /). It is used whenever binary data needs to be stored or transmitted in environments that only handle text.

Common uses of Base64:

  • Data URIs: Embedding images directly in HTML or CSS (data:image/png;base64,...)
  • JWT tokens: The header and payload of JSON Web Tokens are Base64URL encoded
  • Email attachments: MIME encoding uses Base64 for binary attachments
  • API payloads: Transmitting binary data in JSON fields
  • Basic authentication: HTTP Basic Auth encodes credentials as Base64

The size tradeoff: Base64 increases data size by approximately 33%. Three bytes of binary data become four Base64 characters. This makes it unsuitable for large files but perfectly acceptable for small images, tokens, and configuration data.

Unicode handling: The standard JavaScript btoa() function only handles ASCII characters. Our tool uses TextEncoder and TextDecoder to properly handle the full Unicode range, including emoji and multibyte characters.

For URL-safe encoding of query parameters, use the URL Encoder/Decoder. To format JSON data before encoding, try the JSON Formatter.

How to Use This Base64 Encoder/Decoder

  1. Paste or type your input in the editor above
  2. Click the action button or the tool will process automatically
  3. View the result in the output panel
  4. Copy the result with one click using the Copy button

Frequently Asked Questions

Yes. Unlike basic implementations that only handle ASCII, this tool uses TextEncoder/TextDecoder for full UTF-8 Unicode support. Emoji, CJK characters, and all Unicode text encode and decode correctly.

Yes. Upload an image file and the tool outputs a Base64 data URI that you can embed directly in HTML or CSS. You can also paste a Base64 string to preview the decoded image.

Base64 uses 4 characters to represent every 3 bytes of data, resulting in roughly 33% size increase. This is the tradeoff for being able to represent binary data in text-safe formats.

All encoding and decoding happens in your browser. Your data is never sent to any server. You can verify this in your browser Network tab.