Free Base64 Encoder & Decoder
Encode plain text and any file into Base64, or decode Base64 strings back into readable text, images, or downloadable files — instantly, in your browser, with nothing ever uploaded to a server. Paste anything and Auto-detect decides whether it needs encoding or decoding; switch to URL-safe Base64 for tokens and links, control padding and line wrapping, inspect JWT header and payload JSON in one click, and turn images into ready-to-paste data URIs. Built for debugging APIs, auth headers, email payloads, and embedding assets in HTML and CSS.
Padding and line-wrap apply when encoding. Decoding accepts standard or URL-safe input, with or without padding, whitespace, or a data-URI prefix.
📁 Encode a File to Base64
Convert any file (image, PDF, document…) to a Base64 string or a ready-to-paste data URI — fully offline, nothing is uploaded.
How to Use
- 1Leave Auto-detect on and paste anything — text, a Base64 string, or a JWT token. The tool works out the direction itself.
- 2Or pick Encode or Decode explicitly, choose Standard or URL-safe alphabet, and set padding and line-wrap options.
- 3Watch the result convert live as you type — no button press needed. Copy it, download it as a .txt file, or swap it back into the input.
- 4For files, drop any file into the file encoder to get its Base64 string and data URI, with an image preview for pictures.
- 5If a decode turns out to be binary data (an image, PDF, or ZIP), download it as a file with its type auto-detected.
Key Features
- ✓
Auto-detect: paste anything
Leave Auto-detect on and paste whatever you have — plain text, a Base64 string, or a JWT. The tool works out the direction itself, using conservative rules so ordinary words like “password” are encoded, never mangled into nonsense.
- ✓
Live conversion, no button press
The output updates on every keystroke. Change the alphabet, padding, or line-wrap and the result follows instantly — the way a developer tool should feel.
- ✓
Standard and URL-safe alphabets
Encode standard Base64 (+ /) for email, PEM blocks, and data URIs, or URL-safe base64url (− _) for links, cookies, and JWTs. Decoding accepts either form, with or without padding.
- ✓
JWT inspector built in
Paste a JSON Web Token and the tool recognises its three-segment shape, then decodes the header and payload into readable JSON in one click — perfect for debugging auth without leaving the page.
- ✓
Files in, data URIs out
Drop any file — image, PDF, document — and get its Base64 string plus a ready-to-paste data URI, with an image preview for pictures. Everything is read locally; nothing is uploaded.
- ✓
Binary decode that downloads
When a Base64 string decodes to binary instead of text, you don't get a cryptic error — you get a download button, with the file type sniffed from its signature (PNG, JPEG, GIF, WebP, PDF, ZIP, SVG).
- ✓
Errors that say what's actually wrong
Invalid characters, impossible lengths, bad padding, and binary-instead-of-text each get their own specific message — so you can fix the input instead of guessing.
- ✓
100% client-side, honestly private
Encoding and decoding use only built-in browser APIs. There is no server call, no logging, and no upload step — safe even for tokens and sensitive strings.
Frequently Asked Questions
Is Base64 encryption?
What is the difference between standard and URL-safe Base64?
Why does Base64 end with = signs?
Why did my decode fail?
Does this tool handle emoji and non-English text?
Is my data uploaded anywhere?
What is the JWT inspector?
What is Base64 — and why does everything use it?
Base64 is a binary-to-text encoding scheme defined in RFC 4648. It takes any bytes — text, an image, a PDF, a cryptographic token — and rewrites them using just 64 printable ASCII characters: A–Z, a–z, 0–9, plus + and /, with = as padding. The reason is transport: many systems that move data around only handle text safely. Email was built for 7-bit ASCII, JSON has no binary type, URLs and HTTP headers choke on raw bytes, and XML breaks on control characters. Base64 is the bridge that lets binary data travel through all of them unchanged.
You meet it constantly, usually without noticing. Email attachments ride inside MIME bodies as Base64. Small images are inlined into HTML and CSS as data URIs. API credentials travel as Base64 in Authorization headers. JSON Web Tokens are base64url segments. Certificates, keys, and embedded fonts are routinely Base64-encoded before being placed in config files. Whenever you see a long, apparently random string of letters, digits, + and /, there is a good chance it is Base64 — and this tool is how you find out what it actually contains.
How Base64 works, step by step
A byte is 8 bits. Base64 re-reads the same bits in chunks of 6, because 6 bits can take exactly 64 values (0–63), and each value maps to one printable character. The tool processes three bytes at a time: 3 bytes are 24 bits, and 24 bits are exactly four 6-bit chunks — so every 3 bytes of input become exactly 4 characters of output. That is also why Base64 output is always about 33% larger than the input: the price of travelling as text.
| Step | Value (for “Man”) |
|---|---|
| 1. Bytes | M a n = 77, 97, 110 |
| 2. As 8-bit groups | 01001101 01100001 01101110 |
| 3. Same 24 bits, in 6-bit groups | 010011 010110 000101 101110 |
| 4. Each group as a number | 19, 22, 5, 46 |
| 5. Look up in the alphabet | T W F u → TWFu |
When the input length is not a multiple of 3, the last group is short and padding fills it: one leftover byte produces two = signs, two leftover bytes produce one. So “Hello World” (11 bytes) encodes to SGVsbG8gV29ybGQ= — 16 characters, one = of padding. Padding is a convenience for decoders, not a security feature: this tool accepts input with or without it and restores it automatically.
Standard vs URL-safe Base64 — and why JWTs use the second
| Variant | Alphabet positions 62 / 63 | Padding | Used for |
|---|---|---|---|
| Standard (RFC 4648 §4) | + / | = included | Email (MIME), PEM blocks, data URIs |
| URL-safe (RFC 4648 §5) | − _ | Usually omitted | URLs, filenames, cookies, JWTs |
The difference exists because + and / have special meaning inside URLs (+ means a space in query strings; / separates path segments). A token pasted into a URL with those characters intact will be corrupted in transit, which is why JSON Web Tokens always use the URL-safe alphabet — header.payload.signature, three base64url segments joined by dots, padding stripped. Paste one here and the JWT inspector decodes the header and payload into readable JSON. Note the honest limit: decoding a JWT tells you what it claims; it does not verify its signature. For that you need the signing key, which is exactly why the signature segment exists.
Base64 is not encryption — and other pitfalls
The single most important thing to understand about Base64 is what it is not. It is not encryption, not hashing, and not obfuscation that protects anything: there is no key, and anyone with any decoder — including this page — reverses it instantly. Encoding a password or an API secret in Base64 and calling it “hidden” is one of the most common security mistakes in software. Basic Auth headers are Base64-encoded credentials, and they are only safe inside HTTPS, where the transport itself is encrypted.
- Unicode needs UTF-8 first. Text must be converted to UTF-8 bytes before encoding. The browser's raw btoa() only handles Latin-1 and corrupts emoji and non-Latin scripts; this tool uses TextEncoder/TextDecoder, so Bengali, Arabic, Chinese, and emoji round-trip exactly.
- Whitespace is not an error. Base64 copied from emails and logs often contains line breaks and spaces. A forgiving decoder strips them; a strict one fails. This tool strips them, and also strips data-URI prefixes (data:image/png;base64,…) before decoding.
- Not every valid Base64 string is text. A decodes-to- binary result (an image, a PDF, a ZIP) is not a failure — it is a file. Use the download button and let the signature sniffing name the file type for you.
- Size grows by a third. Do not Base64-encode large files for transport unless you must: a 3 MB image becomes a 4 MB string. For data URIs, the rule of thumb is small assets only (under ~10 KB), where saving an HTTP request outweighs the overhead.
Doing it from the command line
For scripts and servers, every platform has a built-in equivalent. On Linux and macOS, echo -n "Hello" | base64 encodes and echo "SGVsbG8=" | base64 -d decodes. In Python, base64.b64encode(b"Hello") and base64.urlsafe_b64encode(...) cover both alphabets; in JavaScript, Buffer.from(text).toString("base64") and Buffer.from(b64, "base64url") do the same. The browser tool above exists for the interactive cases — inspecting a token, checking a payload, building a data URI — where opening a terminal would slow you down. For adjacent jobs, the JWT decoder gives a full token breakdown, the JSON formatter prettifies decoded JSON payloads, and the developer tools collection covers the rest of the workflow.
Related Tools You Might Like
Handy utilities in Developer Tools
JWT Decoder & Verifier
Free JWT decoder and verifier: decode header, payload and claims, check expiry with a live countdown, and verify HS256/RS256/ES256 signatures in your browser. Tokens never leave your device.
JSON Formatter & Validator
Format, validate & beautify JSON free online. Tree view, exact error locations, JSONPath, sort keys & minify — 100% private, in your browser.
Password Generator
Free password generator with exact entropy maths: strong random passwords, EFF passphrases and pronounceable mode. 100% client-side — nothing leaves your browser.