Base64 Encoder / Decoder

Encode any text string to Base64, or decode a Base64 string back to plain text. Commonly used for embedding images in HTML and CSS, encoding API credentials, and storing binary data in JSON or XML. Runs entirely in your browser.

Developer Tools Cluster

Input
📄 Drop a .txt file here, or

What This Tool Does

Encodes text or binary data to Base64 and decodes Base64 strings back to plain text, entirely in your browser. Supports standard Base64, URL-safe Base64, and handles Unicode input correctly.

Who This Is For

  • Developers embedding images in HTML or CSS as data URIs to reduce HTTP requests
  • Engineers encoding credentials for HTTP Basic Authentication headers (username:password)
  • Anyone working with APIs that require Base64-encoded payloads or return encoded responses
  • Security professionals encoding or decoding tokens and binary payloads during testing

Example: Input: A binary image file, or a text string like user:password → Output: The Base64-encoded string, e.g. dXNlcjpwYXNzd29yZA==, ready to use in headers or data URIs

How to Encode or Decode Base64

  1. Encode: paste your plain text into the input field and click Encode. The Base64 string appears in the output.
  2. Decode: paste a Base64 string into the input and click Decode. The plain text (or binary content) appears in the output.
  3. Click Copy to copy the result instantly.

The tool handles standard Base64 and URL-safe Base64. For CSV data, convert CSV to JSON before encoding, or validate JSON before Base64-encoding an API payload. (which uses - and _ instead of + and /). Both are available as output options.

What Is Base64 Encoding?

Base64 is an encoding scheme that converts binary data into a string of 64 printable ASCII characters (A–Z, a–z, 0–9, +, /). It is not encryption — it does not hide the data. Anyone with a Base64 string can decode it instantly.

The name comes from the 64 characters used in the encoding. Every 3 bytes of input data become 4 Base64 characters, so the encoded output is approximately 33% larger than the original.

PropertyBase64URL-Safe Base64
Characters usedA–Z, a–z, 0–9, +, /A–Z, a–z, 0–9, -, _
Padding= (at end)= omitted or replaced
URL safeNo (+, / need escaping)Yes
Used inEmail (MIME), data URLsJWTs, OAuth tokens, URL parameters

Where Is Base64 Used?

Base64 in Code

LanguageEncodeDecode
JavaScript (browser)btoa(str)atob(str)
JavaScript (Node)Buffer.from(str).toString("base64")Buffer.from(b64, "base64").toString()
Pythonbase64.b64encode(b"data")base64.b64decode(encoded)
PHPbase64_encode($str)base64_decode($str)
Bashecho -n "text" | base64echo "encoded" | base64 -d

Note: btoa() and atob() in JavaScript only handle ASCII strings. For Unicode text or binary files, use Buffer in Node.js or the TextEncoder API in browsers.

Encoding Workflow Tools

Base64 encoding is used throughout web development and authentication:

Related Tools

Related Guides & Tutorials

Frequently Asked Questions

Is Base64 encryption?
No. Base64 is an encoding scheme, not encryption. It converts binary data to text for safe transmission — anyone can instantly decode it. Never use Base64 to hide sensitive data. For actual encryption, use AES or a modern authenticated encryption scheme.
Why does Base64 output end with == or =?
The = characters are padding. Base64 encodes 3 bytes into 4 characters. When the input length is not a multiple of 3, padding is added to complete the final group. One = means one byte of padding; == means two bytes.
What is URL-safe Base64?
Standard Base64 uses + and /, which have special meanings in URLs. URL-safe Base64 replaces these with - and _ and typically omits padding. It is used in JWTs, OAuth access tokens, and any context where the encoded string appears in a URL.
Can I Base64 encode an image?
Yes. To embed an image in HTML or CSS as a data URL: encode the image file bytes to Base64, then format it as data:image/png;base64,{encoded}. This eliminates an HTTP request but increases file size by ~33%. Best for small icons only.
Why is my decoded output showing strange characters?
The input is likely binary data (an encoded image, file, or key), not text. Base64 can encode any binary data — not just text. If the decoded result is not readable text, the original was binary.
What is the performance overhead of Base64 encoding?
Base64 increases data size by approximately 33% (every 3 bytes becomes 4 characters). Processing overhead is minimal — encoding and decoding are O(n) operations. The size increase is the primary cost to consider.