What Is Base64?
You have a binary file that needs to travel through an email system designed for text. The email protocol was built in the 1980s and only handles ASCII characters. Send raw binary data through it and the bytes get corrupted. Base64 solves this problem by converting binary data into a string of printable ASCII characters that any text-based system can handle safely.
Base64 was formalized in the MIME (Multipurpose Internet Mail Extensions) standard in 1992, which extended email to support attachments, images, and non-text content. The encoding is defined in RFC 4648, published by the Internet Engineering Task Force (IETF). Today, Base64 is used far beyond email. It appears in JSON Web Tokens (JWTs), data URIs in HTML and CSS, HTTP Basic Authentication headers, and API payloads across the web.
Base64 is not encryption. It does not provide confidentiality or security. Anyone can decode a Base64 string instantly. Its purpose is purely to make binary data safe for text-based transmission. If you need to securely protect data, use encryption algorithms like AES instead.
What This Tool Does
This tool encodes plain text to Base64 and decodes Base64 strings back to plain text. It handles the full Unicode character range by using UTF-8 encoding internally before applying Base64, ensuring that non-ASCII characters (accents, emoji, non-Latin scripts) are handled correctly.
- Encode inputs: Any plain text string, including Unicode characters
- Encode outputs: A Base64 string using the standard alphabet (A-Z, a-z, 0-9, +, /) with = padding
- Decode inputs: A valid Base64 string
- Decode outputs: The original plain text
How the Encoding Works
Base64 works by grouping binary data into 6-bit chunks and mapping each chunk to one of 64 printable characters. The character set is: A-Z (0-25), a-z (26-51), 0-9 (52-61), + (62), / (63). If the input is not a multiple of 3 bytes, = padding is added to complete the final group. This is specified in RFC 4648, which also defines Base32 and Base16 (hex) encoding schemes.
Every 3 bytes of input = 4 Base64 characters
Output size = ceil(input bytes / 3) x 4 characters
This means Base64 always increases data size by approximately 33%. For example, a 3-byte (24-bit) input becomes 4 characters (32 bits). A 1 MB binary file encodes to approximately 1.33 MB of Base64 text. This trade-off is accepted because the encoded output is universally compatible with text-only systems.
How to Use the Tool
- Select the Encode tab to convert plain text to Base64
- Paste or type your text in the input area
- Click Encode to see the Base64 output
- Use the Copy button to copy the result to your clipboard
- Switch to the Decode tab to convert a Base64 string back to plain text
- Paste the Base64 string and click Decode
Example Encodings
Example 1: Simple Text
The text "Hello" encodes to "SGVsbG8=". Breaking it down: H=72, e=101, l=108, l=108, o=111. These 5 bytes become the groups 010010 000110 010101 101100 011010 110110 111000 (padded), mapping to S, G, V, s, b, G, 8, = in the Base64 alphabet. The = at the end signals that one byte of padding was added.
Example 2: JSON Data in a JWT
The JSON string {"user":"admin","role":"superuser"} encodes to "eyJ1c2VyIjoiYWRtaW4iLCJyb2xlIjoic3VwZXJ1c2VyIn0=". This is the format used in JWT (JSON Web Token) payloads, where the header and body are Base64url-encoded JSON objects. A JWT consists of three Base64url sections separated by dots. Pasting the middle section (the payload) into the decode tab reveals the token's claims without needing a dedicated JWT debugger. For URL-specific encoding, use our URL Encode / Decode tool, which handles percent-encoding for web addresses.
Real-World Scenarios
Embedding Images in HTML or CSS
Sarah, a front-end developer in Toronto, needs to embed a 2 KB logo directly in a CSS file to eliminate an additional HTTP request. She encodes the PNG file as a Base64 data URI: background-image: url("data:image/png;base64,iVBORw0K..."). The browser renders the image without fetching a separate file. This technique is common for small icons and sprites but becomes inefficient for large images due to the 33% size overhead. Sarah keeps the file under 4 KB after encoding to avoid bloating her stylesheet. For generating secure credentials to pair with embedded assets, our Password Generator creates strong random passwords for API keys and service accounts.
Debugging an API Authentication Header
Marcus, a backend developer in Berlin, is debugging a 401 error from a REST API. The API uses HTTP Basic Authentication, which encodes the username and password as Base64 in the Authorization header: Authorization: Basic dXNlcjpwYXNzd29yZA==. He pastes "dXNlcjpwYXNzd29yZA==" into the decode tab and sees "user:password". He realizes the API expects the username in a different format. Without this tool, he would have needed to write a script or open a terminal to decode the header.
Inspecting a JWT Token
Priya, a security analyst in Mumbai, receives a JWT from a client application and needs to verify its claims. She splits the token at the dots and pastes the middle section into the decode tab. The output reveals: {"sub":"1234567890","name":"Priya Patel","iat":1516239022}. She can see the subject, name, and issued-at timestamp without installing a JWT library. She notices the token has no expiration claim, which is a security concern she reports to the development team.
Why This Tool Matters
Base64 encoding is a daily tool for web developers, API integrators, and security analysts. Being able to quickly encode and decode strings without writing code speeds up debugging, API testing, and content inspection tasks. The encoding is defined in RFC 4648 and is supported by virtually every programming language, making it a universal format for binary-to-text conversion.
Common Mistakes to Avoid
- Confusing Base64 with encryption: Base64 provides zero security. Never treat a Base64-encoded string as hidden or protected information. It is trivially reversible by anyone with a decoder
- Removing padding characters: The = padding at the end of a Base64 string is required for correct decoding. Removing it may cause errors depending on the decoder. Some URL-safe variants omit padding, but standard decoders expect it
- Using Base64url vs standard Base64: JWTs and URL-safe encoding use a variant that replaces + with - and / with _, and typically omits padding. Standard decoders may fail on these variants. Always check which variant your application expects
- Encoding already-encoded data: Encoding a Base64 string again produces a valid but double-encoded result. Always decode from the original Base64 rather than encoding an already-encoded value. Double encoding inflates the size by another 33%
Limitations of This Tool
This tool accepts text input only. To encode a binary file (such as an image or PDF), you would need to read its raw bytes first, which requires a code-based approach or a dedicated file encoding tool. The tool uses the standard Base64 alphabet defined in RFC 4648. It does not automatically handle Base64url variants (which use - and _ instead of + and /). If you are decoding a JWT payload, you may need to replace - with + and _ with / and add = padding manually before decoding. For hexadecimal number conversions, our Hex Calculator handles base-16 arithmetic and conversions.
Authoritative Research & Resources
- IETF RFC 4648: The Base16, Base32, and Base64 Data Encodings - The official Internet Engineering Task Force standard that defines Base64 encoding, including the character set, padding rules, and URL-safe variants
- IETF RFC 2045: MIME Part One - The original MIME specification that introduced Base64 for email attachments, extending internet email to support non-text content
- IETF RFC 7519: JSON Web Token (JWT) - Defines how JWTs use Base64url encoding for the header and payload sections, relevant to modern web authentication