Skip to content
ZeroServer.tools

Base64 Encoder & Decoder

Encode text or a file to Base64, or decode Base64 back to text or to the file it was: a PDF, a ZIP, an image. Everything happens in your browser; nothing is uploaded.

0 chars
Drop a file to Base64-encode, or click to browseEncodes the file's bytes: a PDF, a Word file, an MP3, an image, anything up to 10 MB.

What is Base64 Encoding?

Base64 writes bytes as text, three bytes to four characters drawn from letters, digits, + and /. It is how a file travels through something that only carries text: an e-mail attachment, a JSON field, an API response, a data: URL in a web page. This page encodes text, as UTF-8, or any file, and decodes Base64 back to the text or to the file it was.

Decoding Base64 to a file

Paste the Base64 of a PDF, a ZIP, a Word or Excel file, an image or a sound, or a whole data: URL, and the page names the file from its first bytes: a PDF starts %PDF-, which is JVBERi0 in Base64, and a ZIP, like every Word and Excel file, starts PK. It offers the file under that type's extension, shows an image, a sound or a video, and opens a PDF in a new tab. Text comes back as text. The Base64 may carry spaces, line breaks, JSON escapes such as \/ or quotes around it; an error names the character and the line it is on.

100% Local Processing

The decoding, the naming and the download all run in this page's own JavaScript, so a contract or a key you decode never leaves your device. The link keeps what you typed, so it can be shared, unless it is longer than a link should hold.

Built and maintained by Meet Shah · Last updated

What this tool is used for

  • Embedding a small PEM certificate or key blob in a YAML file, where the surrounding tooling only accepts a single-line value.
  • Reading a Basic auth header out of a captured request to confirm which account a failing integration is actually using.
  • Moving a binary fixture through a channel that only carries text — a JSON field, an environment variable, a webhook body.
  • Decoding the data URI from a stylesheet to find out what an inlined asset really is and how much weight it adds.
  • Confirming a blob you were sent is genuinely Base64 before treating a decode failure as a transport problem.
  • Turning the Base64 of an invoice or a contract, from an API's JSON response, back into the PDF without sending it to a server.

How it works in practice

A worked example

An integration keeps failing for one account whose password has accented characters in it, and you need the exact header value the client should be sending.

Input
maría:pässwörd
Output
bWFyw61hOnDDpHNzd8O2cmQ=

Fourteen characters came out as twenty-four. Encoding happens over bytes rather than characters, and í, ä and ö each need two bytes in UTF-8, so what goes in is seventeen bytes long before anything is encoded. Seventeen is not divisible by three, which is why the result carries a single = at the end: the last group of four characters is carrying two real bytes instead of three. Put Basic and a space in front of that string and you have the header value, byte for byte.

The edge case that catches people

Run btoa on the same string in a browser console and you get bWFy7WE6cORzc3f2cmQ=, which is four characters shorter and completely different. That function is defined over Latin-1: it maps every code point to exactly one byte, so í becomes one byte where UTF-8 needs two. Above U+00FF it gives up and throws InvalidCharacterError, which is at least loud about it — the range that quietly ruins an afternoon is accented Latin text, where it returns a value your server decodes into mojibake. This page converts to UTF-8 first, which is what an HTTP client actually does.

When not to use this tool

This is a transport encoding, so it is the wrong choice for storage and the wrong choice for size. A column full of it cannot be searched or indexed on what it contains, and inlining an image into a stylesheet costs a third more bytes than the file itself while giving up the separate cache entry the browser would otherwise have kept. If the aim is to keep a value away from whoever can read the page or the network, the word for that is encryption, and nothing here does any.

Frequently Asked Questions

Is Base64 a form of encryption?
No. Base64 is encoding, not encryption — it doesn't protect your data. Anyone can decode a Base64 string instantly. Use it only to represent binary data as ASCII text (e.g. embedding images in CSS or data URIs).
What's the difference between standard Base64 and Base64URL?
Standard Base64 uses + and / which break in URLs and filenames. Base64URL replaces + with - and / with _, making it safe for query strings, JWT tokens, and file names without percent-encoding.
How do I encode a file, such as a PDF, to Base64?
Drop the file on the page, or choose Open a file. The page reads the file's bytes and writes their Base64, up to 10 MB. Choose data: URL to get data:type/subtype;base64,… for an HTML src or a CSS url(), or a line length of 64 or 76 for a PEM block or a MIME part.
How do I turn Base64 back into a PDF or another file?
Switch to Decode and paste the Base64, or the whole data: URL. The page names the file from its first bytes, as the Base64 of a PDF starts JVBERi0 and that of a ZIP or a Word file UEsDB, and offers it under that type's extension. It shows an image, a sound or a video, and opens a PDF in a new tab. Nothing is uploaded.
What are the = padding characters at the end of Base64?
Base64 encodes 3 bytes at a time. When the input length isn't divisible by 3, = padding fills the last group to keep the output a multiple of 4 characters. Some implementations omit padding — the decoder here accepts both.
Why does a decoder call my Base64 invalid?
Usually a character that is not Base64: quotes around it, a JSON escape such as \/ from PHP, a percent escape such as %2F, or a data: URL's header. This page reads each and says so; otherwise its error names the character and where it is. A count of characters one over a multiple of four means one was lost or added.
Why is the encoded length always a multiple of four?
Because three input bytes map to four output characters, and padding fills the final group. That is also why the = characters carry no data — they only record how many bytes the last group actually held.

Common errors and gotchas

  • Pasting a Base64URL string into a standard decoder. The - and _ characters are not in the standard alphabet, and it fails on the first one it meets.
  • Line breaks from a PEM file or a folded mail header. Most decoders tolerate them and some reject them, so strip them before comparing two blobs byte for byte.
  • Assuming the decoded result is text. A PNG or a PDF decoded as text comes out as replacement characters, or as an error from a decoder that insists on UTF-8, which looks like corruption but is not.
  • Expecting the output to be smaller. Four characters carry three bytes, so it always grows by roughly a third.
  • Losing the trailing = when a value passes through something that trims it. Some decoders then refuse the string outright.

Related Encoders & Decoders tools

Private & free — this tool runs entirely in your browser.

IndieKit — Ship your Next.js startup in days.affiliate