What Base64 is, in one minute
Base64 is a way to write any bytes — text, an image, a PDF, a font — using only 64 safe characters: A–Z, a–z, 0–9, + and /, with = as padding at the end. Every 3 bytes of input become 4 characters of output, so Base64 is always about 33% larger than the original (4 ÷ 3 = 1.333). It is not encryption and not compression. Anyone can decode it, so never treat Base64 as a way to hide a password or an API key.
It exists because many systems were built to carry text, not raw bytes. E-mail attachments, JSON APIs, HTML and CSS files, XML documents, environment variables, HTTP Basic authentication headers and JWT tokens all use Base64 to move binary data safely through channels that might otherwise corrupt it.
How to use this Base64 encoder and decoder
- Text tab. Choose Encode or Decode, then type or paste. The result updates as you type. Swap moves the output to the input and flips the direction, which is the fastest way to check a round trip.
- File / image → Base64. Drop any file. You get the Base64 plus ready-to-paste snippets: a full data URI, raw Base64, an HTML
<img>tag, a CSSbackground-imagerule, Markdown or a small JSON object. The panel shows the original size, the Base64 size and the exact overhead, and previews images with their pixel dimensions. - Base64 → file / image. Paste a bare Base64 string, a data URI, a whole
<img src="data:…">tag or a CSSurl(data:…). The tool finds the Base64 inside, decodes it, recognises the real file type from its first bytes (the “magic number”) and lets you download it with the correct extension.
Everything runs inside your browser tab. Files are read with the browser's FileReader and never sent to any server. That matters, because Base64 is often used for exactly the things you should not upload: API credentials, signed documents, certificates and private images. Once the page has loaded it also works offline, and you can install it as an app from the header.
What makes this tool different
- Correct Unicode. The browser's built-in
btoa()throws an error on Hindi, emoji or any character above U+00FF. Many simple sites either fail or silently produce the wrong bytes. Here, text is encoded as UTF-8 by default, exactly as RFC 4648 tools in Python, Java, Go and the command line expect, soनमस्तेand😀survive a round trip. You can also choose ISO-8859-1 (Latin-1) or UTF-16LE when a legacy system needs them. UTF-16LE is common with PowerShell's-EncodedCommand. - URL-safe Base64 both ways. Tick URL-safe to use the base64url alphabet from RFC 4648 section 5, where
-and_replace+and/. JWTs, many OAuth tokens and file-name-safe IDs use it, usually without=padding. When decoding, URL-safe input is detected automatically, and missing padding is added for you. - Precise error messages. If the input is not valid Base64, you see why and where: “Invalid character “#” — position 17”, “‘=’ padding may only appear at the end” or “Wrong length — one Base64 character is missing or extra”. Spaces and line breaks are ignored, as the MIME standard allows.
- MIME and PEM line wrapping. E-mail (RFC 2045) wraps Base64 at 76 characters per line and PEM certificates and keys (RFC 7468) at 64. Choose either to match the system you are feeding.
- Binary detection. If decoded bytes are not valid text, the tool says so instead of showing garbage, names the detected type (PNG, JPEG, PDF, ZIP, MP3, WOFF2 and more) and shows the first bytes in hex.
- Type mismatch warnings. A data URI that says
image/pngbut contains JPEG bytes is flagged, which saves time when an image refuses to display.
Base64 vs base64url vs data URI
| Form | Alphabet / shape | Where you see it |
|---|---|---|
| Standard Base64 | A–Z a–z 0–9 + /, padded with = | E-mail attachments, JSON payloads, PEM files, HTTP Basic auth |
| base64url | A–Z a–z 0–9 - _, padding often dropped | JWT header and payload, OAuth PKCE, URLs and file names |
| Data URI | data:<mime>;base64,<payload> | Inline images in HTML, CSS and e-mail templates |
When to inline an image as Base64 — and when not to
Inlining a small icon, logo or placeholder as a data URI removes one HTTP request and keeps a single HTML file self-contained, which is handy for e-mail signatures, offline reports and tiny widgets. For anything bigger than a few kilobytes it is usually a bad trade: the file grows by a third, the browser cannot cache it separately from the page, and large strings slow down HTML and CSS parsing. Some e-mail clients also block data URIs. As a rule of thumb, inline images under about 4 KB and serve everything else as a normal file. If an image is too large, shrink it first with our image compressor, then encode it here.
Common real-world tasks
- HTTP Basic authentication: encode
username:passwordand send it asAuthorization: Basic <base64>. Remember this is encoding, not encryption, so only use it over HTTPS. - Reading a JWT: paste the middle part (the payload) of a token in Decode mode. URL-safe characters and missing padding are handled automatically, and you can read the JSON claims. The signature cannot be verified this way.
- Kubernetes secrets: values in a Secret manifest are Base64. Decode to check a value, or encode a new one. Watch for a stray newline at the end of the text, which changes the result.
- API uploads: many APIs (document, OCR and e-signature services) accept files as Base64 inside JSON. Use the File tab, choose “Raw Base64 only”, and copy.
- Fixing broken images: paste a data URI from a CMS or e-mail template in the third tab to see whether it really decodes to an image, and which type it is.
Why does the same text give a different Base64 elsewhere?
Base64 encodes bytes, not letters, so the result depends on how the text was turned into bytes. “é” is one byte in Latin-1 but two bytes in UTF-8, so the outputs differ. A trailing newline added by echo on the command line also changes the output: echo "hi" | base64 gives aGkK, while the text “hi” alone gives aGk=. Windows line endings (CRLF) and invisible characters such as a byte-order mark cause the same effect. If two tools disagree, check the character set and the line endings first.
Size limits and performance
Text mode comfortably handles several megabytes. The File tab can encode files of tens of megabytes; very long outputs are shown in part, while Copy and Download always give the full result. Because work happens on your device, the practical limit depends on its memory. Phones handle smaller files than desktops.
Sources and standards
- RFC 4648 — The Base16, Base32, and Base64 Data Encodings (IETF): the standard alphabet, padding and the URL-safe “base64url” alphabet in section 5.
- RFC 2045 — MIME Part One: e-mail Base64 with lines of at most 76 characters.
- RFC 7468 — Textual Encodings of PKIX structures: PEM files wrapped at 64 characters.
- RFC 2397 — The “data” URL scheme: the
data:image/png;base64,format. - MDN Web Docs — Base64: why
btoa()fails on non-Latin-1 text and how to encode UTF-8 correctly.
Frequently asked questions
Is Base64 encryption?
No. Base64 is a reversible encoding that anyone can decode in one step. Use it to transport data safely through text-only channels, never to protect secrets.
Why does btoa() fail on my text?
The browser's btoa() only accepts characters up to U+00FF. Hindi, emoji and most non-Latin text must be converted to UTF-8 bytes first. This tool does that automatically.
What is URL-safe Base64 (base64url)?
It is the RFC 4648 section 5 variant that uses - and _ instead of + and /, so the result can sit in URLs and file names. JWTs use it without = padding. Tick URL-safe to encode; decoding detects it automatically.
How much bigger does Base64 make a file?
About 33%: every 3 bytes become 4 characters. With 76-character MIME line breaks it is about 37%. The File tab shows the exact overhead for your file.
How do I convert a Base64 string back to an image or PDF?
Open the “Base64 → file / image” tab and paste the string or data URI. The tool detects the real type from the file's first bytes, previews images and downloads the file with the right extension.
Are my files uploaded anywhere?
No. Encoding and decoding run entirely in your browser. Nothing is sent to a server, and the page works offline after it loads.
Why is my Base64 different from another tool's?
Usually the text was converted to bytes differently (UTF-8 vs Latin-1 vs UTF-16), or one side included a trailing newline or Windows line endings. Match the character set and line endings and the output will match.