Base64 Encoder Decoder Online Free
Encode any text or file to Base64 and decode Base64 back to readable content instantly. Supports URL-safe mode, UTF-8, binary files, and image preview. Runs entirely in your browser.
How this Base64 encoder and decoder handles text, files, and URL-safe output
Base64 turns arbitrary binary data into a string built from 64 printable characters, so it can travel safely through systems designed for text: JSON fields, URLs, email bodies, HTTP headers. This tool wraps the browser’s own btoa and atob functions, the same primitives every JavaScript Base64 library ultimately calls, and adds the UTF-8 handling and formatting options those two raw functions do not provide on their own.
Every conversion runs locally using btoa, atob, TextEncoder, and FileReader. The script makes no network requests, so text and files you feed in never leave your browser tab.
Why raw btoa fails on real text
The native btoa function only accepts strings where every character code fits in one byte (0 to 255). Feed it an emoji or an accented letter outside that range and it throws InvalidCharacterError. This tool avoids that failure entirely by converting text to UTF-8 bytes first, then treating each byte as its own character before handing the result to btoa.
TextEncoder().encode(text) converts the string into its raw UTF-8 byte sequence, correctly handling multi-byte characters like emoji and non-Latin scripts.
String.fromCharCode, producing a “binary string” where every code point sits safely under 256, exactly what btoa expects.
btoa groups that binary string into 3-byte chunks and maps each 6-bit slice to one of 64 characters (A-Z, a-z, 0-9, +, /), padding the final chunk with = when the input isn’t a multiple of three bytes.
+ becomes - and / becomes _, matching RFC 4648 section 5, so the result can sit in a URL path or query string without escaping.
Decoding: cleanup before the parser sees it
Decoding runs the same idea backward. Input first gets stripped of whitespace and line breaks, then any URL-safe characters get converted back to standard Base64 alphabet characters, then the string is padded to a length divisible by four before atob ever touches it. Skipping that padding step is the single most common reason a hand-rolled Base64 decoder throws on otherwise valid input.
| Alphabet character | Standard mode | URL-safe mode |
|---|---|---|
| 62nd symbol | + | - |
| 63rd symbol | / | _ |
| Padding | = as needed | Same rule, tool re-pads on decode |
| Typical use | Email, JSON payloads | URLs, filenames, JWT segments |
File mode
Drag-and-drop or file picker input goes through FileReader.readAsDataURL, which returns a data URL string; the tool splits off everything after the comma to get the raw Base64 payload, and shows an inline image preview automatically when the MIME type starts with image/.
76-character line wrap
An optional toggle inserts a newline every 76 characters, matching the line length rule from RFC 2045 (MIME), which some older systems and email clients still expect from Base64-encoded attachments.
Encoding specifications
- RFC 4648 is the formal specification for the Base64, Base64url, Base32, and Base16 data encodings.
- MDN: btoa() documents the exact behavior and error conditions of the browser function this tool builds on.
- MDN: TextEncoder covers the UTF-8 encoding step that makes non-Latin text safe to Base64 encode.
- RFC 2045 (MIME Part One) defines the 76-character line wrap convention offered as an option here.
Where Base64 turns up in real systems
Embedding small images directly into CSS or HTML as data URLs, decoding the payload segment of a JWT to inspect its claims, preparing binary attachments for inclusion in JSON API requests, encoding Basic Authentication credentials for an HTTP header, and checking what a Base64 blob you found in a config file or log line actually contains before trusting it.
FAQ: Base64 Encoder Decoder Online Free
Yes, completely free. No account, no trial, and no payment required at any point.
No. Everything happens in your browser using the built-in btoa and atob JavaScript functions. Your text, files, and secrets never leave your device.
Standard Base64 uses plus and forward slash characters which have special meaning in URLs. URL-safe Base64 replaces plus with a minus and forward slash with an underscore, making the output safe to include in URLs and query strings without percent-encoding. Use URL-safe for JWT tokens and API parameters.
Yes. Drop any file onto the upload zone or click to browse. The tool reads it locally and produces Base64 output. For images, you also get a preview so you can confirm the file before copying the result.
Base64 represents every 3 bytes of binary data as 4 ASCII characters. This means the encoded output is always around 33 percent larger than the original input. The stats bar shows you the exact size ratio for each conversion.
Base64 works in groups of 4 characters. When the input does not divide evenly into groups of 3 bytes, one or two equals signs are appended as padding to complete the final group. The stats bar shows how many padding characters were added.
MIME email standards require Base64 encoded content to have a line break inserted every 76 characters. Enable this option when encoding email attachments. Disable it when encoding data for JSON, HTML, or tokens where line breaks would break the format.
Paste the Base64 string into the right output pane, then click Decode from Base64. If you see an error, check that the string is pure Base64 with no surrounding quotes, prefixes like data:image, or extra characters. The tool strips whitespace and line breaks automatically before decoding.
From the blog
Guides, tips, and deep dives
Practical write-ups on the tools, workflows, and questions our users run into most.
Visit the blog