Base64 Encode and Decode Online

Convert text, hex bytes or files to Base64 and decode Base64 back to readable text. Supports Base64URL, MIME line wrapping and more than a dozen character sets, all processed locally in your browser.

Runs entirely in your browser. Nothing is uploaded.

How to use

  1. Choose Encode or Decode at the top of the tool.
  2. Type or paste your text, or click Open file to encode any file.
  3. Adjust the variant (standard or URL-safe), padding, line wrap or text encoding if needed. The result updates as you type.
  4. Copy the result, download it, or press Swap to send it back through the opposite direction.

What is Base64?

Base64 is a binary-to-text encoding that represents any sequence of bytes with 64 printable ASCII characters: A-Z, a-z, 0-9, + and /, with = used for padding. It lets binary data such as images, keys or compressed files travel safely through systems that were designed for text, like email, JSON, XML, URLs and HTML.

The encoder reads the input three bytes (24 bits) at a time and splits them into four groups of 6 bits. Each 6-bit value, from 0 to 63, selects one character of the alphabet. When the input length is not a multiple of three, the last group is padded with one or two = signs. As a result, Base64 output is always about 33% larger than the original data.

Base64 is an encoding, not encryption. Anyone can decode it, so never use it to hide passwords or secrets.

Base64 and Base64URL

Standard Base64 uses + and /, which have special meanings in URLs and file names. Base64URL, defined in RFC 4648 section 5, replaces them with - and _ and usually drops the padding. It is used by JSON Web Tokens, OAuth and anywhere a value must sit inside a URL. The decoder on this page accepts both forms automatically.

Standard Base64Base64URL
Characters 62 and 63+ /- _
PaddingRequired =Optional, usually omitted
Safe in URLs and file namesNoYes
Typical useEmail (MIME), data URIs, JSON, PEM keysJWT, OAuth, URL parameters

Common uses of Base64

  • Email attachments. MIME encodes attachments as Base64 wrapped at 76 characters per line. Use the Line wrap option to reproduce this format.
  • Embedding images and files. Data URIs put small images, fonts or icons directly into HTML and CSS. See Image to Base64 and Base64 to Image.
  • APIs and configuration. JSON has no binary type, so APIs send files, signatures and keys as Base64 strings. Kubernetes Secrets store their values in Base64 as well.
  • Authentication. HTTP Basic authentication sends username:password as Base64, and JSON Web Tokens are three Base64URL segments.
  • Certificates and keys. PEM files are Base64-encoded DER data wrapped at 64 characters per line.

Base64 in programming languages

LanguageEncodeDecode
JavaScript (browser)btoa(binaryString)atob(base64)
Node.jsBuffer.from(str).toString('base64')Buffer.from(b64, 'base64').toString()
Pythonbase64.b64encode(data)base64.b64decode(data)
PHPbase64_encode($str)base64_decode($b64)
JavaBase64.getEncoder().encodeToString(bytes)Base64.getDecoder().decode(b64)
C#Convert.ToBase64String(bytes)Convert.FromBase64String(b64)
Gobase64.StdEncoding.EncodeToString(b)base64.StdEncoding.DecodeString(s)
Shellbase64 file.binbase64 -d file.txt

In browsers, btoa only accepts characters up to U+00FF. To encode Unicode text, convert it to UTF-8 bytes first, for example with TextEncoder, or use this tool, which encodes text as UTF-8 by default.

More than Base64

Base64.is also covers the rest of the Base-N family: Base32, Base58, Base62, Base85, Ascii85, basE91, Base45, hex and binary. If you are not sure which encoding a string uses, try the encoding detector, or compare all of them at once with All Encodings.

Specification

AlphabetA-Z a-z 0-9 + /
Output size4 characters per 3 bytes (about 133%)
Padding= to a multiple of 4 characters
StandardRFC 4648 section 4
Case sensitiveYes

Examples

Input (UTF-8)Output
Hello, World!SGVsbG8sIFdvcmxkIQ==
Base64.isQmFzZTY0Lmlz
你好5L2g5aW9

Frequently asked questions

Is my data uploaded to a server?

No. Encoding and decoding run entirely in your browser with JavaScript. The text and files you enter never leave your device, and the tool keeps working offline once the page has loaded.

Why does the decoded text look garbled?
Either the data is binary (for example an image or a compressed file) rather than text, or it was encoded with a different character set. Try another option in Text encoding, choose Hex output, or use Base64 to File to download and identify the bytes.
What do the equals signs at the end mean?

They are padding. Base64 works in blocks of four characters, and = fills the last block when the input length is not a multiple of three bytes. One = means the last block encodes two bytes, two mean it encodes one byte.

How much bigger does data get when encoded?

Base64 turns every 3 bytes into 4 characters, so the output is about 33% larger than the input, plus line breaks if you enable line wrapping.

Is Base64 a form of encryption?

No. Base64 only changes how data is represented. It has no key and anyone can decode it, so use real encryption such as AES or TLS to protect sensitive information.

All Base64 and encoding tools