Base64 / Base32 / Base58 / Base85 Encoder — Free Online Tool

Base64 encode/decode: text, files, images, binary. URL-safe Base64, decode to text/hex. Online Base64 converter with file upload support.

Use this free online Base64 / Base32 / Base58 / Base85 Encoder directly in your browser. No signup required, no data leaves your device. Part of Utilier — a collection of 133+ developer utilities.

What is Base64 Encoder/Decoder (Text, File, Image, URL-Safe)?

Base64 encoder converts binary data to ASCII text using 64 printable characters (A-Z, a-z, 0-9, +, /). Used for: embedding images in HTML/CSS (data URLs), email attachments (MIME), API authentication (Basic Auth), storing binary in JSON/XML (text-only formats). Encoding: 3 bytes → 4 ASCII characters (33% size increase). Decoding: reverses process (Base64 text → original binary). Features: text encoding (UTF-8 → Base64), file encoding (upload → Base64 string), image encoding (→ data URL), URL-safe variant (+ → -, / → _, no padding =), decode to text/hex/binary. Use cases: data URLs (embed images in CSS), JWT tokens (header.payload.signature), API keys (binary → transmittable string), email attachments (binary → 7-bit ASCII).

  • Text to Base64: UTF-8 text → Base64 ASCII. Example: 'Hello' → 'SGVsbG8=' (6 chars → 8 Base64 chars). Reversible: 'SGVsbG8=' → 'Hello'. Use: transmit text safely (no special chars), store in JSON.
  • File/Image encoding: Binary file → Base64 string. Image upload → data URL: data:image/png;base64,iVBORw0KG... (embeddable in HTML <img src='data:...'> or CSS background). Large files = very long strings (33% larger).
  • URL-safe Base64: Standard Base64 uses +, /, = (not URL-safe). URL-safe: + → -, / → _, padding = removed. Example: 'a+b/c=' → 'a-b_c'. Use: tokens in URLs, filenames (no escaping needed).
  • Decoding: Base64 string → original data. Text: 'SGVsbG8=' → 'Hello' (UTF-8). Binary: decode to hex (00 48 65 6C 6C 6F) or file download. Validates: invalid chars → error.
  • Padding (=): Base64 output length must be multiple of 4. Padding = added if needed. Example: 'Hello' → 'SGVsbG8=' (1 padding char), 'Hi' → 'SGk=' (1 =), 'H' → 'SA==' (2 =). Decoding: padding removed/optional.

Why use base64?

Transmit binary data over text-only channels (email, JSON, URLs). Embed resources in code.

  • Embed images in HTML/CSS: Data URL: <img src='data:image/png;base64,iVBORw...'> (no separate image file request). CSS: background-image: url(data:...). Reduces HTTP requests (faster load), but larger HTML (33% overhead).
  • Email attachments (MIME): Email (SMTP) = 7-bit ASCII only. Binary attachments → Base64 (8-bit → 7-bit). Example: PDF attachment encoded in MIME multipart. Recipient: decodes to original binary.
  • JSON/XML binary data: JSON/XML = text formats (no binary). Store binary: encode as Base64 string. Example: {"file": "SGVsbG8="} (binary data as text). API responses: images, PDFs as Base64.
  • API authentication: HTTP Basic Auth: username:password → Base64 → Authorization: Basic dXNlcjpwYXNz. Not encryption (easily decoded), just encoding for transmission. Use with HTTPS (secure channel).
  • JWT tokens: JWT = header.payload.signature (all Base64-encoded JSON). Example: eyJhbGc... (header) . eyJzdWI... (payload) . signature. Decodes to JSON objects. URL-safe Base64 (no padding).
  • Binary in URLs: URL parameters = text only. Binary ID → Base64 (URL-safe): id=a-b_c (- and _ safe, no + or /). Or filenames: image-a_b.png (no special chars).

When to use base64

Use when encoding binary for text transmission or embedding resources.

  • Embedding images in HTML/CSS (data URLs, inline images).
  • Storing binary data in JSON/XML (API responses, config files).
  • Email attachments (MIME encoding for SMTP transmission).
  • API authentication (Basic Auth header encoding).
  • JWT tokens (header and payload encoding).
  • Binary data in URLs (URL-safe encoding for query params).
  • Encoding files for upload (binary → text for form submission).
  • QR codes (data URLs for inline QR images).

How to use base64

Enter text or upload file, encode to Base64, or decode Base64 to original.

  1. Encode text: Input text: 'Hello World'. Select: Encode. Output: 'SGVsbG8gV29ybGQ=' (Base64 string). UTF-8 text → Base64 ASCII. Copy result for use in JSON, APIs.
  2. Encode file/image: Upload file (image, PDF, binary). Tool reads file → Base64 string. Image: outputs data URL (data:image/png;base64,...). Copy data URL → paste in <img src='...'> or CSS.
  3. Decode Base64: Input: 'SGVsbG8=' (Base64 string). Select: Decode. Output: 'Hello' (original text). Or decode to hex (48 65 6C 6C 6F). File: download decoded binary.
  4. URL-safe encoding: Option: URL-safe Base64. Standard: 'a+b/c=' → URL-safe: 'a-b_c' (+ → -, / → _, no =). Use for: tokens in URLs, filenames. No percent-encoding needed.
  5. Validate Base64: Paste Base64 string → decode. Invalid chars (not A-Z, a-z, 0-9, +, /, =) → error. Length not multiple of 4 (with padding) → invalid. Tool shows error message.
  6. Copy result: Encode: copy Base64 string. Decode: copy text or download binary file. Data URL: copy entire data:image/... string (use in HTML, CSS).

Key features

  • Text encoding: UTF-8 text → Base64 ASCII. Example: 'Hello' → 'SGVsbG8='. Multi-language support (UTF-8: emoji, Chinese, Arabic). Decode: Base64 → original text.
  • File upload encoding: Upload image, PDF, binary file → Base64 string. File reader: reads binary → encodes. Output: raw Base64 or data URL (for images). Max size: browser limits (typically 50-100MB).
  • Data URL generation: Image upload → data URL: data:image/png;base64,iVBORw0KG... MIME type auto-detected (PNG, JPG, GIF, SVG). Embed in HTML: <img src='data:...'>, CSS: background-image.
  • URL-safe variant: Option: URL-safe Base64 (RFC 4648). Changes: + → -, / → _, padding = removed (optional). Use: JWT tokens, URL params, filenames. No percent-encoding (%2B for +).
  • Decode to multiple formats: Base64 input → decode to: text (UTF-8), hex (48 65 6C 6C 6F), binary (file download). Auto-detect: text vs binary. Invalid UTF-8 → show hex/binary only.
  • Validation: Checks: valid characters (A-Z, a-z, 0-9, +, /, =), correct padding (length % 4 == 0), proper structure. Errors: invalid character, incorrect padding, malformed input.
  • Bidirectional conversion: Encode: text/file → Base64. Decode: Base64 → text/file. Toggle modes. Real-time encoding (type → instant Base64 output). No server (client-side only, privacy).

Common use cases

  • Inline images (data URLs): Small logo: upload → data URL: data:image/png;base64,iVBORw... Use in HTML: <img src='data:...'> (no external file). Reduces HTTP requests (1 less request). Trade-off: larger HTML (33% overhead).
  • API image upload: POST /api/upload with JSON: {"image": "iVBORw0KG..."} (Base64-encoded image). Server decodes → saves file. Alternative to multipart/form-data. Simpler for JSON APIs.
  • Email attachment: SMTP email with PDF attachment. Encode PDF → Base64. MIME: Content-Transfer-Encoding: base64. Body: Base64-encoded PDF. Receiver decodes → original PDF.
  • JWT token: JWT header: {"alg":"HS256","typ":"JWT"} → Base64: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9. Payload: {"sub":"1234"} → eyJzdWIiOiIxMjM0In0. Signature: Base64. Token: header.payload.signature (URL-safe, no padding).
  • Basic Auth header: Username: user, Password: pass. Encode 'user:pass' → Base64: dXNlcjpwYXNz. HTTP header: Authorization: Basic dXNlcjpwYXNz. Server decodes → validates credentials. Use with HTTPS (not encrypted).
  • QR code data URL: Generate QR code → PNG image → Base64 data URL. Display: <img src='data:image/png;base64,...'> (inline QR, no file). Print receipts, tickets (embedded QR).

Examples

Common Base64 encoding and decoding examples.

Encode text

Hello World
Base64: SGVsbG8gV29ybGQ=

UTF-8 text 'Hello World' (11 chars) → Base64 'SGVsbG8gV29ybGQ=' (16 chars). Decode reverses.

Decode Base64

SGVsbG8=
Decoded: Hello

Base64 'SGVsbG8=' → text 'Hello'. 1 padding char (=). Original: 5 bytes.

URL-safe encoding

a+b/c (standard Base64)
URL-safe: a-b_c

+ → -, / → _, padding = removed. Safe in URLs: no need for %2B, %2F encoding.

Data URL (image)

Image file (PNG)
data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...

Binary image → Base64 data URL. Use in HTML: <img src='data:image/png;base64,...'> (inline image).

JWT header

{"alg":"HS256","typ":"JWT"}
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9

JSON header → Base64 (URL-safe, no padding). JWT token = header.payload.signature (all Base64).

Technical reference

Base64 encoding specifications and format details:

Character set
64 characters: A-Z (26), a-z (26), 0-9 (10), + (1), / (1). Padding: = (used for alignment). Total: 65 chars. Case-sensitive: A ≠ a.
Encoding process
3 bytes (24 bits) → 4 Base64 chars (6 bits each). Example: 'ABC' (41 42 43 hex) → 010000 010100 001001 000011 (24 bits) → 16, 20, 9, 3 (indices) → Q, U, J, D (Base64). Reversible: QUJD → ABC.
Size overhead
Base64 = 33% larger than original. 3 bytes → 4 chars (4/3 = 1.33). Example: 300 KB file → 400 KB Base64. With padding: slightly more. Trade-off: size for text compatibility.
Padding
Output length must be multiple of 4. If not: add = padding. Example: 'A' (1 byte) → QQ== (2 padding), 'AB' (2 bytes) → QUI= (1 padding), 'ABC' (3 bytes) → QUJD (no padding). Decoder: ignores/removes padding.
URL-safe Base64
RFC 4648 §5. Changes: + → - (minus), / → _ (underscore), = padding optional (usually omitted). Example: standard 'a+b/c=' → URL-safe 'a-b_c'. Use: URLs, filenames (no escaping: %2B for +).
Line breaks
MIME Base64 (email): max 76 chars per line, CRLF breaks. RFC 2045. Example: long Base64 split into multiple lines. Decoder: ignores line breaks (strips before decoding). Tool: no line breaks (single string).
Invalid characters
Only A-Z, a-z, 0-9, +, /, = valid. Others: error. Whitespace (space, tab, newline): ignored or error (depends on decoder). Tool: strict (no whitespace in output, optional in input).
Binary vs text
Base64 works on bytes (binary). Text: UTF-8 → bytes → Base64. Binary: raw bytes → Base64. Decode: bytes → interpret as UTF-8 (text) or raw (binary). Invalid UTF-8: show hex/binary.
Data URL format
data:[<mediatype>][;base64],<data>. Example: data:image/png;base64,iVBORw... Media type: image/png, text/html, application/pdf. ;base64 = encoding. <data> = Base64 string.
Security note
Base64 is encoding, NOT encryption. Easily decoded (no secret key). Example: Basic Auth 'dXNlcjpwYXNz' → 'user:pass' (plaintext). Always use HTTPS for sensitive data. Base64 = obfuscation, not security.

Common mistakes to avoid

Using Base64 for encryption (it's encoding, not secure)

Why it happens: Base64 easily decoded (no key needed). Example: 'dXNlcjpwYXNz' → 'user:pass' (anyone can decode). Not secure (visible to attackers).

How to avoid it: Use encryption (AES, RSA) for security. Base64 = encoding for transmission (not hiding data). Always HTTPS for sensitive data (encrypts channel, not just Base64).

Not using URL-safe Base64 for URLs/filenames

Why it happens: Standard Base64: + and / invalid in URLs (need %2B, %2F escaping). Filename: / is path separator (breaks paths). Example: token=a+b/c → a%2Bb%2Fc (ugly, longer).

How to avoid it: Use URL-safe Base64: + → -, / → _. Example: a-b_c (no escaping needed). Set option in tool or use URL-safe encoding function.

Large data URLs (slow page load)

Why it happens: Image 500 KB → Base64 665 KB → data URL in HTML. Entire HTML + Base64 = large (slow download). Browser: can't cache data URL (re-downloaded with HTML every time).

How to avoid it: Use data URLs for small images only (<10 KB: icons, logos). Large images: external files (browser caches, parallel downloads). Data URL = convenience vs performance trade-off.

Incorrect padding (length not multiple of 4)

Why it happens: Base64 output must be multiple of 4 chars. Example: 'SGVsbG8' (7 chars, missing 1 =) → invalid. Decoder error: incorrect padding. Some decoders lenient (add padding), others strict (error).

How to avoid it: Use tool (auto-adds padding). Manual: add = until length % 4 == 0. Example: 'SGVsbG8' → 'SGVsbG8=' (8 chars). Check output before using.

Forgetting UTF-8 encoding (wrong characters)

Why it happens: Text 'café' (UTF-8: C3 A9 for é) → Base64. Decode with wrong encoding (Latin-1) → wrong char. Example: é (UTF-8) decoded as Latin-1 → é (mojibake).

How to avoid it: Always UTF-8 for text. Tool: defaults to UTF-8 (ensure option set). Decode: same encoding as encode. Mismatch → garbled text.

Frequently asked questions

What is the difference between Base64 encoding and encryption?

Base64 = encoding (reversible without key, anyone can decode). Encryption = requires secret key to decrypt. Base64: 'SGVsbG8=' → 'Hello' (easy). Encryption: ciphertext → plaintext (only with key). Use Base64 for transmission, encryption for security.

Why is Base64-encoded data larger than the original?

3 bytes → 4 Base64 chars (4/3 = 1.33, 33% larger). Example: 300 KB → 400 KB Base64. Trade-off: size for text compatibility (binary → ASCII, safe for email/JSON).

What is URL-safe Base64?

Standard: +, /, = chars (not URL-safe). URL-safe: + → -, / → _, = removed. Use in URLs, filenames (no escaping). Example: 'a+b/c=' → 'a-b_c' (safe in URL query params).

Can I encode any file type to Base64?

Yes. Base64 works on bytes (binary). Any file (image, PDF, video, ZIP) → Base64 string. Decode: Base64 → original binary file. Large files → very long Base64 strings (consider size).

What is a data URL?

data:[<mediatype>][;base64],<data>. Example: data:image/png;base64,iVBORw... Embeds resource in URL (no external file). Use in HTML <img src='data:...'>, CSS background. Inline resources (no HTTP request).

Why does Base64 have padding (=)?

Output must be multiple of 4 chars (encoding 3-byte groups). Not multiple? Add = padding. Example: 'A' (1 byte) → 'QQ==' (2 =), 'AB' → 'QUI=' (1 =), 'ABC' → 'QUJD' (no =). Decoder: uses padding to determine original byte count.

Is Base64 case-sensitive?

Yes. A-Z and a-z are different characters (52 total). Example: 'A' (index 0) ≠ 'a' (index 26). Changing case: 'SGVsbG8=' ≠ 'sgvsbg8=' (different data). Must match exactly when decoding.

References

Privacy and availability

  • Runs entirely in your browser — zero server processing
  • No signup or account required
  • Works offline once loaded
  • Fast, lightweight, no external dependencies
  • Available as a browser extension for Chrome and Firefox