Encode and Decode Base64 Online
September 4, 2026
Written by Mohammad Sohail
Base64 is a encoding scheme that converts binary data into ASCII text. It is used everywhere on the web — in data URLs, email attachments (MIME), HTTP headers, JWT tokens, and API authentication. Knowing how to encode and decode Base64 is essential for developers, security testers, and anyone working with web APIs.
What Base64 Actually Does
Base64 takes every 3 bytes of binary data and converts them into 4 ASCII characters from the set A-Z, a-z, 0-9, +, and /. The result is about 33% larger than the original data. For example, the word 'Hello' (5 bytes) becomes 'SGVsbG8=' (8 characters). The '=' at the end is padding.
When You Need Base64
Embedding images directly in HTML or CSS using data URLs (data:image/png;base64,...). Decoding JWT tokens to inspect payload claims. Encoding credentials for HTTP Basic Authentication (Authorization: Basic dXNlcjpwYXNz). Sending binary file content in JSON APIs. Debugging email headers.
What I Tested
I used the Base64 Encoder/Decoder with several inputs.
• Text 'Hello, World!' → Encoded: 'SGVsbG8sIFdvcmxkIQ==' (16 characters). Round-trip decoded back to 'Hello, World!' correctly.
• Text 'https://www.freedigitaltoolkit.com' → Encoded: 'aHR0cHM6Ly93d3cuZnJlZWRpZ2l0YWx0b29sa2l0LmNvbQ==' (56 characters). Decoded correctly.
• Empty string '' → Encoded: '' (empty). No padding added. Correct behavior.
• Decoded invalid Base64 '!!!invalid!!!' → Error message: 'Invalid Base64 input'. The tool does not crash or produce garbage output.
Step-by-Step
(1) Open the Base64 Encoder/Decoder. (2) Paste your text in the input field. (3) Click 'Encode' to convert to Base64, or 'Decode' to convert from Base64. (4) Copy the result.
Limitation
Base64 is encoding, not encryption. It provides zero security. Anyone can decode a Base64 string instantly. Never use Base64 to hide passwords, API keys, or sensitive data. Use proper encryption (AES, RSA) for that.
Common Mistake
Including line breaks in Base64 strings. Some systems (especially email) insert line breaks at 76 characters. If your decoder fails, remove all line breaks and whitespace before decoding. Our tool handles this automatically — it strips whitespace before processing.
How It Compares
CyberChef (by GCHQ) is a powerful encoding toolkit but has a steep learning curve with hundreds of options. Base64decode.org works but shows ads and requires uploading text to their server. Our tool encodes and decodes instantly in your browser with a clean interface and no server upload.
Privacy: All encoding and decoding happens in your browser. Your data is never sent to any server.
Next Step: If you need to URL-encode the Base64 output for use in query parameters, use the URL Encoder to convert special characters to percent-encoded format.
Base64 Variants You Will Meet
Three forms turn up in practice. Standard Base64 (A-Z, a-z, 0-9, +, /) is what MIME email, data URIs and most APIs use, always with padding. URL-safe Base64 replaces + and / with - and _ so the string can sit in a path or query without escaping, and usually drops the = padding entirely. Base32 is a separate, longer alphabet used for two-factor secrets because it avoids ambiguous characters.
The practical consequence: a string generated for a URL will fail in a strict MIME decoder, and a MIME result will need percent-encoding before it goes into a query parameter. When you see an unexpected symbol at a known position, it is almost always a variant mismatch rather than corrupted data.
Data URLs: Inlining Images in HTML and CSS
A data URL embeds the encoded bytes directly in the markup: data:image/png;base64,iVBORw0KGgo... It removes one network request and works when a page must render with no external assets, which is why icons and small logos are often inlined. The costs are real, though — the encoded image is a third bigger, it cannot be cached separately, and it inflates every file it appears in, so one image shared across five stylesheets is downloaded five times.
The useful range is small graphics under a few kilobytes: favicons, UI glyphs, spacer images. Photographs and screenshots should stay as files, where the browser caches them once and compression still applies to the transfer.
Transporting Base64 Safely
Base64 strings travel well but get damaged easily when passed through systems that treat them as ordinary text. Email clients, chat apps and URL bars can insert line breaks, strip trailing equals signs, or turn plus characters into spaces — each of which corrupts the payload the next time you decode it.
When sending Base64 through a channel you do not control, wrap it in a plain-text envelope or encode the string itself as a URL-safe component so it survives the trip. On receipt, check the length before decoding: a string whose length is not a multiple of four has lost characters or padding, and the decoder will either fail outright or return bytes that are subtly wrong.
Frequently Asked Questions
Why does Base64 output end with = signs?
Base64 works on three bytes at a time, producing four characters. When the input is not an exact multiple of three, the last group is padded with = so every decoder knows how many bytes to read back. One equals sign means two bytes in the final group, two equals signs mean one byte.
Why is the result about a third longer than the input?
Each group of three input bytes becomes four output characters, so the encoding grows by four over three — exactly 33 percent plus padding. That overhead buys you text that survives any channel that only accepts letters, numbers and a few symbols.
What is the difference between standard and URL-safe Base64?
Standard Base64 uses + and / in its alphabet, which need escaping inside query strings and file names. URL-safe Base64 swaps them for - and _ and often drops the padding, so the result can go straight into a URL without percent-encoding. If a decoder rejects your string, try the other variant.
Is Base64 safe for storing or sending passwords?
No. Base64 is an encoding, not encryption — it is trivially reversible by anyone, including a script that does it in one line. Use a password hash with a salt instead, and treat any Base64 string as visible text wherever it travels.
Can this tool encode an image or a file?
It encodes text. Binary files such as PNGs use the same alphabet, but their bytes have to be read first — that happens in a file-conversion tool or a library, not by pasting the raw file contents into a text box.
Related Guides
Try it yourself
Open Tool →