HomeFormattersDataBase64 Encoder / Decoder

Base64 Encoder / Decoder

Data

Encode any text or data to Base64, or decode Base64 strings back to plain text instantly. Free, client-side — nothing you paste is ever uploaded.

What is a Base64?

A Base64 Encoder / Decoder converts text to and from Base64 encoding — a scheme that represents binary or text data using only 64 safe ASCII characters (A–Z, a–z, 0–9, +, /) plus = for padding. Base64 was originally designed to allow binary file attachments to pass through email systems that only supported 7-bit ASCII text. Today it is ubiquitous in web development: HTTP Basic Auth headers, JWT tokens, data URIs for embedded images, and binary data in JSON APIs all rely on Base64.

This tool handles Unicode text correctly by encoding the input as UTF-8 bytes before applying Base64, ensuring that non-ASCII characters (accented letters, Indian scripts, emoji) are encoded faithfully and can be decoded back without loss. The encoder uses the standard Base64 alphabet; decoding accepts standard Base64 with or without padding.

Base64 is an encoding, not encryption — anyone who sees a Base64 string can decode it in seconds. If you need to protect data, use encryption separately from encoding.

For URL encoding needs, the URL Encoder / Decoder handles percent-encoding. For JSON formatting, see the JSON Formatter.


How to use this Base64 calculator

  1. Paste your input text (or Base64 string) into the Input field.
  2. Select Encode → Base64 or Decode ← Base64 from the Mode selector.
  3. The output appears instantly in the Output field.
  4. Click the copy icon on the output field to copy the result.
  5. For decoding, ensure the input uses only valid Base64 characters (A–Z, a–z, 0–9, +, /, =).

Formula & Methodology

Encoding (text → Base64):
1. Convert the input string to UTF-8 bytes (handles Unicode correctly)
2. Group bytes into 3-byte chunks
3. Convert each 3-byte chunk (24 bits) into four 6-bit values
4. Map each 6-bit value to a character in the Base64 alphabet (A–Z = 0–25, a–z = 26–51, 0–9 = 52–61, + = 62, / = 63)
5. Append = padding if the input length is not a multiple of 3

Decoding (Base64 → text):
1. Strip whitespace
2. Map each Base64 character back to its 6-bit value
3. Reassemble 6-bit groups into 3-byte chunks
4. Decode the bytes as UTF-8 text
5. Return a clear error if any character is outside the Base64 alphabet

Valid example: Hello, World!SGVsbG8sIFdvcmxkIQ==

Invalid decode example: SGVsbG8!! is not a valid Base64 character
Frequently Asked Questions
What is Base64 encoding?
Base64 is a binary-to-text encoding scheme that converts arbitrary data into a string of 64 ASCII characters (A–Z, a–z, 0–9, +, /). It is designed to safely transmit binary data over channels that only support text, such as email (MIME), HTTP headers, and JSON payloads. Base64 is an encoding, not encryption — it provides no security.
When should I use Base64 encoding?
Use Base64 when you need to embed binary data in a text-based format. Common scenarios include: embedding images as data URIs in HTML/CSS, encoding authentication credentials in HTTP Basic Auth headers, encoding file attachments in email (MIME), and passing binary data through JSON APIs. Base64 is also used in JWT tokens to encode the header and payload sections.
Does Base64 encoding compress data?
No — Base64 increases the size of the original data by approximately 33%. Every 3 bytes of input become 4 Base64 characters. If you need to reduce data size, compress first (gzip, deflate) and then Base64-encode the compressed output if the transport channel requires text.
What is the = padding at the end of a Base64 string?
Base64 encodes 3 bytes at a time into 4 characters. When the input length is not a multiple of 3, one or two = characters are appended to pad the output to a multiple of 4 characters. One = means one padding byte was needed; == means two were needed. Padding is required by the standard but some implementations omit it — both forms are usually accepted by decoders.
What is URL-safe Base64?
Standard Base64 uses + and / characters, which have special meanings in URLs. URL-safe Base64 replaces + with - and / with _, making the encoded string safe to use in URL query parameters without additional percent-encoding. This tool uses standard Base64 — if you need URL-safe output, replace + with - and / with _ after encoding.
Can I encode images with this tool?
This tool encodes text input — it accepts Unicode text and produces the Base64 representation of the UTF-8 bytes of that text. To encode binary files like images, use a dedicated file encoder. For embedding images in HTML, the data URI format is: data:image/png;base64,[encoded string].
Is Base64 safe to use for passwords or secrets?
No. Base64 is trivially reversible — anyone who sees a Base64 string can decode it in seconds. Never use Base64 to 'hide' passwords, API keys, or sensitive data. For secure storage use a strong hash (bcrypt, Argon2) for passwords, and for transmission use HTTPS with proper authentication.
Is my data stored when I use this tool?
No. All encoding and decoding runs entirely in your browser — nothing is transmitted to any server or stored anywhere. This is important for any sensitive text you might be Base64-encoding, such as API tokens or credentials passed in headers.
Why does decoding return garbled text?
If decoded text appears garbled, the original data was not plain text — it was binary data (an image, a compressed file, a compiled binary). Base64 decoding always produces the original bytes; if those bytes are not valid UTF-8 text, they cannot be rendered as readable characters. This tool handles UTF-8 text; binary file decoding requires a separate file-download step.
What is the difference between encodeURIComponent and Base64?
Both are text-safe encoding schemes but for different purposes. Base64 converts any bytes to a 64-character alphabet suitable for embedding in text formats like JSON or email. encodeURIComponent (percent-encoding) converts characters not allowed in URLs to their %XX hex equivalents, preserving the URL structure. Use Base64 for embedding data; use percent-encoding for URL parameters. You can use the [URL Encoder / Decoder](/url-encoder-formatter/) for percent-encoding.
How do I decode a JWT token?
A JWT (JSON Web Token) has three Base64URL-encoded parts separated by dots: header.payload.signature. To inspect the claims, Base64-decode the second part (the payload). Replace any - with + and _ with / before decoding (JWT uses URL-safe Base64). Note that decoding a JWT does not verify its signature — never trust JWT claims without signature verification on the server side.