Base64 Encoder Decoder Online Free

💻 Developer Tools ✔ Free Forever

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.

✔ Text encode and decode ✔ URL-safe Base64 ✔ File to Base64 ✔ Image preview ✔ 100% browser-based
Encoding
Charset
Plain Text Input
📁 Drop a file here or click to upload
Any file type supported. Results appear as Base64 in the output.
File preview
Preview
Base64 Output
Decode error
About This Tool

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.

Step 1 UTF-8 encode TextEncoder().encode(text) converts the string into its raw UTF-8 byte sequence, correctly handling multi-byte characters like emoji and non-Latin scripts.
Step 2 Bytes to binary string Each byte becomes one character via String.fromCharCode, producing a “binary string” where every code point sits safely under 256, exactly what btoa expects.
Step 3 Standard Base64 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.
Step 4 Optional URL-safe swap If URL-safe mode is on, + becomes - and / becomes _, matching RFC 4648 section 5, so the result can sit in a URL path or query string without escaping.
// simplified from encodeText() in the tool source var bytes = new TextEncoder().encode(text); var binary = ; for (var i = 0; i < bytes.length; i++) { binary += String.fromCharCode(bytes[i]); } var encoded = btoa(binary); if (urlSafe) { encoded = encoded.replace(/\+/g, ‘-‘).replace(/\//g, ‘_’); }

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 characterStandard modeURL-safe mode
62nd symbol+-
63rd symbol/_
Padding= as neededSame rule, tool re-pads on decode
Typical useEmail, JSON payloadsURLs, filenames, JWT segments
Base64 output is always about a third larger. Three raw bytes become four encoded characters, a fixed 4:3 expansion ratio (roughly 133 percent), before any line-wrap characters are added. The stat panel’s compression ratio reflects this directly: encoding a 100-byte file typically reports close to 133 percent, not the shrinkage people sometimes expect from the word “encoding.”
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.

btoa / atob TextEncoder / TextDecoder FileReader.readAsDataURL

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.

Common Questions

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.

Privacy Overview

Cookies let this site remember your preferences and show us which tools people actually use. Full detail sits in our Privacy Policy.