Base64 Encoder / Decoder & Image to Base64 Converter 2026 — Free Online Tool

Encode & decode text, images & files.

Quick Answer

Encode text or images to Base64, or decode Base64 strings back to plain text/images. Features standard Base64, URL-safe Base64, and image Data URI generators with 100% private client-side processing.

Last updated: 2026-07-31 Editorially reviewed by PakDigitalz Editorial Team

Encode and decode Base64 strings, convert images to Data URIs, decode JWT tokens, and generate SHA hashes — all 100% client-side in your browser. Supports UTF-8 multi-byte characters, URL-safe mode (RFC 4648), and instant code snippet generation.

Input (Plain Text / UTF-8)0 Bytes
Output (Base64)0 B

How to Use This Tool

  1. Choose a tool: Text, Image/File, JWT Decoder, Hash Generator, Random Token, or Batch.
  2. For Text: Type or paste your string, select Encode or Decode, toggle URL-Safe mode if needed.
  3. For Images: Drag and drop or click to upload any PNG, JPG, WebP, or SVG file (max 10MB).
  4. For JWT: Paste a JSON Web Token to decode header, payload, and view expiration time.
  5. Copy the generated output, HTML tag, CSS snippet, or download as .txt file.

Formula & Specifications

Base64 Encoding Math & Logic:
- Maps 3 bytes (24 bits) into 4 printable ASCII characters (4 × 6 bits)
- Characters used: A-Z (0-25), a-z (26-51), 0-9 (52-61), + (62), / (63)
- URL-Safe Variant (RFC 4648): replaces '+' with '-' and '/' with '_'
- Size Inflation: Base64 data is ~33% larger than raw binary source bytes
- Padding: '=' character used when input length is not divisible by 3

About Base64 Encoder / Decoder & Image to Base64 Converter

Encode and decode Base64 strings, convert images to Data URIs, decode JWT tokens, and generate SHA hashes — all 100% client-side in your browser. Supports UTF-8 multi-byte characters, URL-safe mode (RFC 4648), and instant code snippet generation.

Frequently Asked Questions

What is Base64 encoding?

Base64 is a binary-to-text encoding scheme that converts binary data into a set of 64 ASCII characters (A-Z, a-z, 0-9, +, /). It is used to transmit binary data over text-based protocols like HTTP, email (MIME), JSON, and XML. Base64-encoded data is approximately 33% larger than the original binary data.

How to encode a string to Base64 in JavaScript?

In JavaScript, use the built-in btoa() function: btoa('Hello') returns 'SGVsbG8='. For Unicode strings, use TextEncoder: const bytes = new TextEncoder().encode('Hello'); btoa(String.fromCharCode(...bytes)). Modern browsers also support atob() for decoding Base64 strings back to text.

What is the difference between standard Base64 and URL-safe Base64?

Standard Base64 (RFC 4648) uses the characters '+' and '/' with '=' padding. URL-safe Base64 replaces '+' with '-' and '/' with '_', and typically strips padding. URL-safe Base64 is used in JWT tokens, URL query parameters, and filenames where '+' and '/' have special meanings.

How to decode Base64 online?

To decode Base64 online: 1) Paste your Base64 string into the input field, 2) Select 'Decode' mode, 3) The decoded text appears instantly. Our free tool supports UTF-8 multi-byte characters (emoji, accented characters) and handles both standard and URL-safe Base64 formats.

How to convert an image to Base64?

To convert an image to Base64: 1) Drag and drop your PNG, JPG, or WebP file into our tool, or click 'Select File', 2) The image is automatically read using the browser's FileReader API, 3) A Data URI like 'data:image/png;base64,iVBORw0...' is generated. You can then copy the Data URI for use in HTML <img> tags or CSS background-image properties.

Is Base64 encoding the same as encryption?

No, Base64 is an encoding, not encryption. It is a reversible transformation that does not provide any security. Anyone can decode Base64 strings without a key. For sensitive data, use proper encryption (AES, RSA) BEFORE Base64-encoding the ciphertext. Never use Base64 alone to protect passwords, API keys, or tokens.

What is a JWT token and how does it use Base64?

A JWT (JSON Web Token) is a compact, URL-safe token format used for authentication. It consists of three Base64-URL-encoded parts separated by dots: Header.Payload.Signature. Example: 'eyJhbGc.eyJzdWIi.SflKxw'. Paste a JWT into our decoder to instantly view the header and payload as JSON.

What is a Data URI?

A Data URI is a URI scheme (data:[<mediatype>];base64,<data>) that embeds data directly into HTML or CSS instead of referencing an external file. For example, '<img src="data:image/png;base64,iVBOR..." />' displays an image without a separate HTTP request. Data URIs are commonly used for small images, icons, and inline SVGs.

Why is Base64 33% larger than the original data?

Base64 encodes every 3 bytes (24 bits) of input into 4 ASCII characters. Each output character represents 6 bits. The ratio is 4/3 ≈ 1.33, so encoded data is approximately 33% larger than the original. For example, a 100KB image becomes ~133KB as a Base64 string.

What are the 64 characters used in Base64?

The Base64 character set consists of: uppercase A-Z (values 0-25), lowercase a-z (values 26-51), digits 0-9 (values 52-61), and two special characters '+' (value 62) and '/' (value 63). The '=' character is used for padding when input length is not divisible by 3. URL-safe Base64 uses '-' and '_' instead of '+' and '/'.

How to encode a file to Base64 in Python?

In Python, use the base64 module: import base64; with open('file.pdf', 'rb') as f: encoded = base64.b64encode(f.read()).decode('utf-8'). To decode: with open('output.pdf', 'wb') as f: f.write(base64.b64decode(encoded)). For URL-safe: use base64.urlsafe_b64encode() instead.

Can Base64 encode emoji and Unicode characters?

Yes, modern Base64 encoders handle UTF-8 Unicode. The process: 1) Convert the string to UTF-8 bytes (e.g., '😀' becomes 4 bytes: 0xF0 0x9F 0x98 0x80), 2) Encode the byte array to Base64. Example: Base64 of '😀' is '8J+YgA=='. Our online tool uses TextEncoder/TextDecoder for full UTF-8 support including emoji.

Is it safe to use online Base64 tools for sensitive data?

It depends on the tool. Our Base64 converter runs 100% in your browser using JavaScript — no data is ever sent to a server. This is safe for API keys, tokens, and sensitive strings. Avoid online tools that process data on their servers when working with confidential information. Always check the tool's privacy policy.

What is the maximum size of a Base64-encoded string?

There is no theoretical maximum, but practical limits depend on: 1) Browser memory (~100-500MB typical), 2) URL length limits (2000-8000 characters), 3) HTTP header size (8KB typical), 4) Email attachment limits. For images, keep Base64 strings under 100KB for best performance, or use URLs for larger files.

How to use Base64 in CSS?

Use Base64-encoded images in CSS with the background-image property: .icon { background-image: url('data:image/png;base64,iVBORw0...'); }. This eliminates extra HTTP requests for small images. For SVG, you can also use url('data:image/svg+xml;base64,...'). Inline Base64 is cached differently than external files.

Related Tools

Need to calculate something else?

Explore our suite of 70+ free tools. Type what you need below to search instantly.

Expert Note

This tool uses the latest international formulas and rates. Results are for estimation purposes. For legal or financial decisions, consult a qualified professional. Built and maintained by the PakDigitalz team.

Explore 70+ more free tools on PakDigitalz.com

View All Tools