Base64 Encoder / Decoder
Encode and decode Base64 strings instantly. Supports UTF-8, one-click copy, and swap. Free, client-side, no signup.
How to Use
- Select Encode or Decode mode.
- Paste or type your text in the input panel.
- Click Go to convert.
- Click Copy to copy the result, or Swap to reverse the operation.
What Is Base64?
Base64 encoding converts binary data into a set of 64 printable ASCII characters (A-Z, a-z, 0-9, +, /). It increases the data size by approximately 33% but ensures safe transmission over text-based protocols that may not handle binary data correctly.
The name "Base64" refers to the 64-character alphabet used in the encoding. Each Base64 digit represents exactly 6 bits of data, so three bytes (24 bits) of input produce four Base64 characters of output. When the input length is not a multiple of three, the output is padded with = characters to maintain alignment.
How Base64 Encoding Works
The encoding process follows three steps. First, the input bytes are grouped into blocks of three (24 bits total). Second, each 24-bit block is split into four 6-bit groups. Third, each 6-bit value is mapped to a character in the Base64 alphabet. For example, the text "Hi" (two bytes: 0x48 0x69) becomes "SGk=" — the padding character fills the missing third byte.
Decoding reverses this process: each Base64 character maps back to its 6-bit value, the bits are concatenated, and the result is split into 8-bit bytes to recover the original data.
Common Use Cases
- Data URIs — Embedding small images directly in HTML or CSS as
data:image/png;base64,...eliminates an extra HTTP request - Email attachments (MIME) — SMTP was designed for 7-bit ASCII text, so binary attachments must be Base64-encoded
- HTTP Basic Authentication — Credentials are sent as
username:passwordBase64-encoded in the Authorization header - JSON and XML payloads — Binary data like images or files can be embedded in text-based formats using Base64
- JWT tokens — JSON Web Tokens use Base64url encoding (a URL-safe variant) for their header and payload segments
- Cryptographic operations — Keys, signatures, and certificates (PEM format) are stored as Base64-encoded strings
Base64 vs. Base64url
Standard Base64 uses + and / as the 62nd and 63rd characters, with = for padding. These characters have special meaning in URLs and filenames. Base64url replaces + with - and / with _, and often omits padding. You will encounter Base64url in JWT tokens, URL parameters, and filename-safe contexts.
Base64 Is Not Encryption
A common misconception is that Base64 provides security. It does not. Base64 is a reversible encoding — anyone can decode a Base64 string without any key or secret. Never use Base64 to protect passwords, API keys, or sensitive data. For actual security, use proper encryption algorithms like AES or asymmetric encryption. If you need to generate secure credentials, try our Password Generator. Generate cryptographic hashes with the Hash Generator. Decode JWT tokens which use Base64url encoding. Encode special characters for URLs with the URL Encoder or for HTML with the HTML Entity Encoder.
Working with Base64 in Code
In JavaScript, use btoa() to encode and atob() to decode. For Unicode text, wrap with encodeURIComponent/decodeURIComponent to handle multi-byte characters. In Python, use the base64 module: base64.b64encode() and base64.b64decode(). In command-line environments, use base64 (macOS/Linux) or certutil -encode (Windows).
Performance Considerations
Base64 increases data size by approximately 33%, which means a 1 MB file becomes about 1.33 MB when encoded. For small assets like icons (under 2–5 KB), embedding as data URIs saves HTTP requests and improves page load times. For larger files, the size overhead outweighs the benefit — serve them as separate files instead. Also consider that Base64-encoded data cannot be cached independently when embedded inline, unlike separate files that benefit from browser caching.
Not Sure What You Have?
If you have a mystery string and aren't sure whether it's Base64, a JWT, a URL-encoded value, or something else entirely, try Paste Anything — it auto-detects the format and routes you to the right tool. You can also chain multiple decodings together with the Pipeline Builder. Need to convert an image file to Base64? Use the Image to Base64 Converter for drag-and-drop conversion with Data URI, CSS, and HTML output formats.
Learn More
- What Is Base64 Encoding? — how it works, when to use it, and common pitfalls.
- Are Online Dev Tools Safe? — why client-side tools like CodeTidy keep your data private.
Frequently Asked Questions
- What is Base64 encoding?
- Base64 is a binary-to-text encoding scheme that represents binary data as an ASCII string. It is commonly used to embed images in HTML/CSS, transmit binary data over text-based protocols like email (MIME), and encode credentials in HTTP Basic Authentication.
- Is Base64 encryption?
- No. Base64 is an encoding, not encryption. It does not provide any security — anyone can decode a Base64 string. Never use Base64 to protect sensitive data.
- Does this tool support Unicode?
- Yes. This tool handles UTF-8 text including non-ASCII characters like accented letters, emojis, and CJK characters.
- Is my data safe?
- Yes. All encoding and decoding happens in your browser using native JavaScript functions. No data is sent to any server.
Code Examples
Learn how to use this tool programmatically in your favorite language.
Use this tool from AI agents.
The CodeTidy MCP Server lets Claude, Cursor, and other AI agents
use this tool and 46 others directly. One command: npx @codetidy/mcp