ToolMight LogoToolMight

Base64 Encoder / Decoder

Encode text as Base64 or decode Base64 back into UTF-8 text directly in your browser. Processing happens locally in client-side memory, so your input is not sent to ToolMight's servers.

Loading Tool...

Learn About This Tool

Base64 encoding fundamentals

Base64 is encoding, not encryption.Base64 changes how data is represented; it does not hide data or require a secret key. Anyone with the Base64 string can decode it back to original text.

Base64, defined in RFC 4648, represents binary bytes using a 64-character printable ASCII alphabet (A-Z, a-z, 0-9, +, and /).

During encoding, every 3 bytes (24 bits) of data are split into 4 6-bit groups and mapped to Base64 characters. This increases the encoded data size by approximately 33.3%.

// Standard Text Input:
Developer Tools

// Base64 Encoded Output:
RGV2ZWxvcGVyIFRvb2xz

When input length is not a multiple of 3 bytes, trailing = padding characters are added: 1 leftover byte yields == padding, while 2 leftover bytes yield = padding.

Base64 and UTF-8 text

Native browser functions like btoa() and atob() operate on 8-bit Latin-1 strings. Passing multi-byte UTF-8 characters (such as emojis or non-Latin scripts) directly to btoa() causes a character encoding exception.

To process UTF-8 text safely, applications convert text strings into byte arrays using TextEncoder before Base64 encoding, and reconstruct UTF-8 strings using TextDecoder after Base64 decoding.

Standard Base64 vs Base64URL

Standard Base64 contains characters that carry special handling requirements in URL contexts:

FeatureStandard Base64Base64URL
Characters 62 & 63+ and /- and _
= PaddingStandardCommonly omitted
Typical useGeneral data transmissionURLs, query strings, and JWT tokens

Base64URL replaces + with - and / with _ to avoid URL parameter encoding conflicts. For inspecting tokens encoded with Base64URL, see our JWT Decoder and URL Encoder / Decoder.

Common uses for Base64

Base64 is commonly used across web infrastructure and protocols:

  • HTTP Basic Authentication: Encodes username:password into request headers (e.g., Authorization: Basic dXNlcjpwYXNz). Note: Base64 does not encrypt credentials; Basic Authentication must be transmitted over HTTPS. To translate terminal cURL commands with basic auth or bearer tokens into application code, use our cURL to Code Converter.
  • Data URIs: Embeds small SVG icons, fonts, or assets directly into HTML or CSS files (e.g., data:image/svg+xml;base64,...) to inline resources without separate HTTP requests.

How to Use Base64 Encoder / Decoder

1

Enter text or a Base64 string

Paste your input text into the text area.

2

Choose Encode or Decode

Select Encode to convert UTF-8 text to Base64, or Decode to convert Base64 back into UTF-8 text.

3

Copy the result

Click Copy Output or press Ctrl+Shift+C to copy the result. Press Ctrl+L to clear the input field.

Code Implementations

Copy & paste production-ready code snippets for Base64 Encoder / Decoder in your language of choice

File: base64_tool.py
Python
import base64

def encode_base64(text: str) -> str:
    return base64.b64encode(text.encode('utf-8')).decode('utf-8')

def decode_base64(encoded_str: str) -> str:
    return base64.b64decode(encoded_str.encode('utf-8')).decode('utf-8')

raw = "Hello, ToolMight Developer!"
encoded = encode_base64(raw)
decoded = decode_base64(encoded)

print(f"Encoded: {encoded}")
print(f"Decoded: {decoded}")

Frequently Asked Questions

No. Base64 is an encoding scheme, not encryption. Anyone can decode Base64 strings back to original text without a secret key.
The = character is padding. Base64 processes data in 3-byte blocks. If the input string has 1 remaining byte, == is added; if 2 remaining bytes, = is added.
Native btoa() expects 8-bit Latin-1 strings. UTF-8 multi-byte characters require converting text to a byte array using TextEncoder before encoding.
Base64URL replaces + with - and / with _ to prevent URL parameter encoding conflicts, commonly omitting trailing = padding.
Base64 encoding and decoding are performed locally in your browser memory sandbox. Your input is not sent to a ToolMight server.
This tool decodes Base64 into UTF-8 text. Base64 strings representing raw binary files (such as images or compiled binaries) do not contain valid UTF-8 character sequences.

Related tools