What is Base64?

Base64 writes any data, such as an image or a file, as plain text with 64 characters: the letters A to Z and a to z, the digits 0 to 9, and two more. Every three bytes become four characters, and when the data doesn't fill the last group, one or two = signs pad it out. Email attachments, data: URLs and many APIs use it. A URL-safe form, used in web addresses and JSON Web Tokens, swaps + and / for - and _ and often leaves out the padding.

You'd check Base64 when a decoder reports an error, or when you build a form or an API that receives it.

Tool description

Paste text into the Base64 box, and the result shows as you type: "Base64 is valid" or "Base64 is not valid". Spaces and line breaks around the text are ignored, but inside it they make it fail, so join Base64 that an email or a key file split into lines. The Variant menu sets which form of Base64 passes, and starts on Standard.

The four variants

Here is Party?! written in each variant:

  • Standard: + and /, and a length that's a multiple of four, padded with = where needed: UGFydHk/IQ==
  • Standard without padding: the same characters, no = at all, and any length: UGFydHk/IQ
  • URL-safe: - and _ in place of + and /, and no =: UGFydHk_IQ
  • URL-safe with padding: - and _, a length that's a multiple of four, and = where needed: UGFydHk_IQ==

Each of these fails in the other three variants. Base64 that has none of +, /, - and _ and needs no padding, such as SGkh for Hi!, passes in all four.

What fails

  • In the padded variants, a length that isn't a multiple of four: Y2FrZQ (cake without its padding) fails, Y2FrZQ== passes
  • In the variants without padding, any =, since "without padding" means none at all: Y2FrZQ== fails, Y2FrZQ passes
  • Three = signs, or = anywhere but at the end
  • The data: start of a data URL: paste only the part after the comma

Good to know

  • The check looks at the characters and the length, not at what they decode to: sunshine passes, though it decodes to nonsense.
  • In the variants without padding, any length passes, even a single character, which no encoder makes.
  • To see what Base64 holds, paste it into the Base64 Decoder, which skips line breaks. To make Base64, use the Base64 Encoder.

Features

  • Checks standard and URL-safe Base64
  • With or without padding
  • Ignores spaces and line breaks around the text
  • Runs in your browser, so nothing you type is sent anywhere