Base64 Encoder

Encode and decode Base64 text.

Input

Auto: Encoding

Ln 1, Col 11 lines, 46 characters

64 characters

A Base64 encoder and decoder that fixes what is broken

Paste text, Base64 or a file and the result updates as you type. It encodes, decodes, repairs damaged Base64 and shows what is inside, all without leaving your browser.

  • It knows which way to go. Leave the direction on Auto detect and the tool decides. Paste Base64 and it decodes, type a sentence and it encodes. Not what you wanted? Switch to Encode or Decode in one click.
  • Reads Base64 in the wrong shape. Data URIs, Authorization: Basic headers, PEM blocks, a data URI buried inside HTML or CSS, and text wrapped over many lines are all unwrapped for you. A JSON Web Token is split into its readable header and payload.
  • Tells you what is wrong and fixes it. Missing padding, a stray character, characters Base64 does not use, mixed +/ and -_ alphabets and joined strings are each explained in plain words. Fix input replaces the text with clean Base64, and Undo brings your original back.
  • Files in, files out. Drop an image, PDF or any file up to 20 MB to encode it byte for byte. Decode Base64 that holds a file and the tool names the type, shows an image preview, gives a hex dump and lets you download the real file.
  • Ready-to-paste output formats. Wrap the result as a data: URI, a CSS url(), an img tag, an HTTP Basic header or a PEM block with your own label. Choose the standard or URL-safe alphabet and turn padding on or off.
  • Line length and text encoding. Wrap lines at 64 (PEM), 76 (MIME) or any length, with LF or CRLF line breaks. Convert text as UTF-8, UTF-16, Latin-1 or ASCII, and get a warning if a character cannot be represented.
  • Batch mode. Turn on Each line separately to encode or decode a whole list, one value per line, and keep the lines aligned.

How this Base64 tool compares with other online tools

Most online Base64 tools encode or decode text and stop there. Here is what you usually get from a basic one and what this tool adds.

This Base64 tool compared with typical online Base64 tools
FeatureTypical online toolThis tool
Your dataSome tools send your text or file to a server.Everything runs in your browser. Nothing you paste or open is uploaded.
DirectionYou pick encode or decode, and the wrong choice gives garbage.Auto detect picks for you, and you can still override it.
Broken inputA vague "invalid input" message, or silently wrong output.Names the problem, such as missing padding, and repairs it in one click.
Unicode textOften breaks on accents, emoji or non-Latin scripts.UTF-8 by default, with UTF-16, Latin-1 and ASCII when you need them.
URL-safe Base64A separate tool, or not offered.One switch for the alphabet and one for padding, and both are detected when decoding.
FilesText only, or encode only.Encode any file, decode to a real file with its type, preview and hex dump.
Output formatsPlain Base64 only.Data URI, CSS, HTML, Basic auth and PEM, plus custom line length.

How to encode and decode Base64

  1. Type or paste into the Input box, drop a file onto it, or press Open file. The badge shows whether it is encoding or decoding.
  2. Read the result in the Output tab and press Copy, or Download to save it as a file.
  3. If the input has a problem, press Fix input in the card under it. The Issues tab lists everything that was found.
  4. Press Swap (Ctrl or Cmd + Enter) to use the result as the next input, for example to check a round trip.
  5. Open Settings for the alphabet, padding, line length, text encoding and output format. Use Inspect for a file preview and hex dump.

Base64 questions

Is my data uploaded anywhere?

No. Encoding, decoding, fixing and file handling all run in your browser, and nothing is sent to a server.

What is Base64 used for?

Base64 turns any bytes into plain letters, digits and a few symbols, so binary data can travel through systems built for text. It is used for email attachments, data URIs, HTTP Basic authentication, JSON Web Tokens and PEM certificates.

Is Base64 encryption?

No. Anyone can decode it, and it adds no secrecy. It makes data about 33% larger and is only a way of writing bytes as text, so never use it to hide a password or secret.

What is the difference between standard and URL-safe Base64?

Standard Base64 uses + and /, which have special meaning in URLs and filenames. URL-safe Base64 uses - and _ instead and usually drops the = padding. JSON Web Tokens use the URL-safe form. When decoding, the tool accepts either.

What is the = at the end?

It is padding. Base64 works in groups of 4 characters, and one or two = signs fill the last group when the data does not divide evenly. Many systems drop it, so a missing = is reported as a warning and still decodes.

Why does decoding say there is one stray character?

Base64 data can never leave exactly one character over after the last full group of four. It usually means the text was cut off or has an extra character at the end. Fix input drops the stray character so the rest can be read.

Why do accents and emoji come out wrong in some tools?

The text has to be turned into bytes first, and tools that use a single-byte encoding cannot hold characters outside it. This tool uses UTF-8 by default, which handles every character. If you pick Latin-1 or ASCII, characters that do not fit are replaced and you get a warning.

How big a file can I convert?

Files up to 20 MB. Base64 is about a third larger than the original, so a 15 MB file becomes roughly 20 million characters, and very large results are slower to display.