Base64 Encoder / Decoder
Encode and decode text, files, and images to Base64
Base64 Encoder / Decoder tool
Base64 Encoder / Decoder: key facts
- What it does
- Encode and decode text, files, and images to Base64
- Category
- Developer Tools
- Cost
- Free, with no account, sign-up, or install.
- Your data
- Runs entirely in your browser — the files and text you enter are never uploaded to a server.
- Last reviewed
- . Report an incorrect result.
What this tool is for
Base64 rewrites arbitrary bytes as a short run of letters, digits, and two punctuation marks — the trick that lets an image sit inside a stylesheet, a PDF travel inside a JSON field, and a token survive a URL. This tool moves data in both directions, across two tabs: Text for strings you can type or paste, and Files & Images for anything you drop in from disk.
The Text tab converts as you type. Leave it on Auto and it inspects what you pasted, then tells you which way it went — a small badge reads "Detected: Base64 → text (decoding)" so the guess is never silent. Alongside standard Base64 you can switch the alphabet to Base64URL for tokens, Base32 for systems that dislike mixed case, or plain Hex, and pick UTF-8 or Latin-1 for how characters map to bytes.
The Files & Images tab handles the other half of the job. Encoding accepts several files at once and reports each one's real MIME type, dimensions for images, and Base64 length; decoding works backwards from a pasted string, identifies the payload from its file signature, previews it, and hands you a correctly typed download.
How to use the Base64 Encoder / Decoder
- Open the Text tab for strings, or Files & Images for anything on disk.
- Paste into the input and read the result underneath — conversion is live, and the Auto badge shows whether your input was treated as text or as an encoded string.
- Adjust the alphabet (Base64, Base64URL, Base32, Hex) or the character set if the receiving system expects something specific; open Advanced for padding, line wrapping at 76 characters, and the split chunk size.
- Tick "Verify round-trip" when correctness matters — it re-decodes the output and compares SHA-256 digests of the original and recovered bytes.
- For files, drop them in and choose how the output is shaped: raw Base64, a data URI, a CSS background-image rule, an HTML img tag, or a JSON object.
- To rebuild a file, switch Files & Images to "Base64 → file", paste the string, check the detected type and preview, name the file, and download it.
- Copy or download the result, or press Swap to push the output back into the input with the direction flipped.
What the Base64 Encoder / Decoder gets right
- Auto-detection is deliberately conservative: a candidate must be at least eight characters, use a valid alphabet, and decode to something text-like, so ordinary words such as "password" get encoded instead of silently mangled into nonsense.
- Pasted input is cleaned before decoding — line breaks and spaces are stripped, a data URI prefix is removed, URL-safe dashes and underscores are mapped back, and absent padding is restored — so the string you copied from a log or an email just works.
- Line wrapping and padding overrides are applied only when encoding, so choosing them can never corrupt decoded text.
- Round-trip verification is a genuine byte-for-byte check with the Web Crypto API, not a guess: if the output does not reproduce the source bytes exactly, it says so.
- Decoding a file identifies the payload by its signature — PNG, JPEG, GIF, WebP, PDF, ZIP, and others — and downloads it with that MIME type, instead of dumping an untyped blob.
- Everything runs in your browser using built-in APIs, with no upload step. History is kept in memory for the session and only written to this device if you tick "Remember on this device".
Frequently Asked Questions
Why did my short word get encoded instead of decoded?
Because plenty of ordinary words are technically valid Base64 — "test" and "password" both are. Auto mode therefore requires a candidate to be reasonably long and to decode into readable text before it will treat it as encoded data. If you genuinely need a short string decoded, click Decode to override the guess.
Why is the encoded output about a third larger than my file?
Base64 spends four output characters on every three input bytes, so the result grows by roughly 33 percent before any line breaks are added. That overhead is why inlining a large asset as a data URI usually costs more than linking to it — the browser cannot cache the inlined copy separately, and it inflates whatever document carries it.
Which alphabet should I pick?
Standard Base64 for general use and MIME. Base64URL when the value goes into a URL path, query string, filename, or JWT, since it avoids the plus and slash characters and drops padding. Base32 when the target is case-insensitive or the value gets read aloud or typed by hand. Hex when you want a direct one-byte-per-two-digits view for debugging.
Does Base64 protect my data?
Not at all — anyone can reverse it, which is the whole point of an encoding. Treat a Base64 string as readable text: it hides nothing. If the contents are sensitive, encrypt them first and encode the ciphertext.
Can I turn a Base64 string back into a real image or PDF?
Yes. Switch the Files & Images tab to "Base64 → file" and paste the string, with or without a data URI prefix. The tool inspects the leading bytes to work out what the payload is, shows a thumbnail for images or an excerpt for text, and downloads it with the right extension and MIME type.