# Base64 Encoder and Decoder

> Advanced online Base64 encoder/decoder. Handles UTF-8 issues, supports URL-safe format, and explains the encoding principle. Free to use.

URL: https://acrafto.com/en/base64-encoder-decoder/

Tools are interactive browser apps; there is no public API, no endpoints to call and no server-side processing. To use a tool, open its HTML page in a browser.

Do you need to convert readable text to Base64 format for use in HTTP headers, or conversely, decipher the content of an API token? Our **Base64 Text Encoder & Decoder** is a specialized tool for working with text strings that can handle intricacies like diacritics or special characters.

> **Working with images?**  
> If your code starts with `data:image/png...` or you want to convert a file to text, this tool will only show you gibberish. Please use our specialized tool for image conversion.

## How does the Base64 format work?

Many people use Base64 daily, but few know how it works “under the hood.” It’s not magic, but simple bitwise mathematics.

Regular text in a computer is stored in 8-bit units (1 byte). Base64, however, uses an “alphabet” of 64 characters (`A-Z`, `a-z`, `0-9`, `+`, `/`). Since `2^6 = 64`, one Base64 character represents exactly **6 bits** of information.

**Conversion Process (Algorithm):**

1. Take three characters of your text (3 × 8 bits = 24 bits).
2. These 24 bits are divided into four groups of 6 bits.
3. Each group is assigned a character from the Base64 table.

**Consequence:** Because we convert 3 characters into 4 characters, the resulting Base64 string is always approximately **33% longer** than the original text.

## Character Set Problem: Why do common Base64 converters corrupt Czech text?

If you’ve ever tried to encode the word “Kůň” in a browser console using the `btoa('Kůň')` function, you probably got an error: *String contains characters outside of the Latin1 range.*

Base64 was originally designed for 7-bit ASCII characters. However, Czech, emojis, and other special symbols (UTF-8) occupy more bytes in memory (multibyte characters).

- Letter `a` = 1 byte.
- Letter `ř` = 2 bytes.
- Emoji 🚀 = 4 bytes.

Our tool solves this problem. Before encoding to Base64, we correctly convert the text into a sequence of UTF-8 bytes. This allows you to safely encode JSON objects, Czech texts, and modern symbols without the risk of data corruption.

## Where is Base64 text encoding used?

While Base64 images are mainly used for embedding in CSS/HTML, text-based Base64 has entirely different applications in backend systems:

### 1\. HTTP Basic Authentication

When you log in to an API, the header often looks like this: `Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=` Behind this code is simply a combined username and password in the format `username:password`. Our tool allows you to easily generate or check these headers.

### 2\. JSON Web Tokens (JWT)

Modern web applications use what are called JWTs for authentication. Such a token looks like three long strings separated by dots. The data part (Payload) is a plain JSON object encoded in Base64.

- **Tip:** Try pasting the middle part of your JWT token here and decoding it. You will see exactly what data the application stores about you (e.g., user ID, expiration).

### 3\. Configuration Files (Kubernetes Secrets)

Platforms like Kubernetes store secrets in YAML configuration files using Base64. This is not encryption, but a way to store binary data or text with problematic characters (newlines, quotes) in a text file.

## What is “URL Safe Base64 encoding” and why does it matter?

The standard Base64 alphabet contains the characters `+` (plus) and `/` (slash). Both of these characters have special meanings in URLs:

- `/` separates directories.
- `+` is often interpreted as a space.

If you were to send standard Base64 in a URL parameter (e.g., `site.com?token=ab/cd+ef`), the server might misinterpret the data.

**Solution (URL Safe mode):** Our toggle activates the **Base64URL** variant (according to RFC 4648), which performs these changes:

- `+` changes to `-` (hyphen).
- `/` changes to `_` (underscore).
- At the end, `=` characters (padding) are removed, as they are not needed in URLs.

---

## Myth: Base64 is not encryption!

It is important to understand a fundamental difference that beginners often confuse:

1. **Encoding (Base64):** Used for data transmission. It’s like packing an item in a suitcase so it doesn’t break during transit. Anyone who finds the suitcase can open it (decode) and see the contents. **It is not secure for sensitive data.**
2. **Encryption (AES, RSA):** Locks data with a key. Without the key, you cannot access the content.
3. **Hashing (SHA, MD5):** A one-way process (e.g., for storing passwords). The original text cannot be retrieved from the result.

*If you need to send a password or sensitive information, Base64 alone is not enough. You must use HTTPS (SSL/TLS) to encrypt the transmission.*

---

## Frequently Asked Questions (FAQ)

### What do the "=" characters at the end of the string mean?

This is called "padding." Because Base64 encodes data in groups of 3 characters, the length of the original text may not be divisible by three. The \`=\` characters are added to the end so the decoder knows how many bits to ignore at the end.

### Why does the decoded text appear as "gibberish"?

You are likely trying to decode data that is not text. If a Base64 string represents a compressed file (ZIP), an image, or encrypted data, converting it to text (UTF-8) does not make sense. Try to determine the origin of the data.

### Does the tool work offline?

Yes. All conversion logic is written in JavaScript and runs directly in your browser. Once the page loads, you can disconnect from the internet, and the tool will still function. Your data is not sent anywhere.

## Other languages

- Čeština (cs): [Base64 Encoder a Decoder](https://acrafto.com/cs/base64-decoder-encoder/) ([Markdown](https://acrafto.com/cs/base64-decoder-encoder/index.md))
- Slovenčina (sk): [Base64 kódovač a dekódovač](https://acrafto.com/sk/base64-kodovac-dekodovac-online/) ([Markdown](https://acrafto.com/sk/base64-kodovac-dekodovac-online/index.md))
- Deutsch (de): [Base64 Encoder und Decoder](https://acrafto.com/de/base64-encoder-decoder-online/) ([Markdown](https://acrafto.com/de/base64-encoder-decoder-online/index.md))
- Français (fr): [Encodeur et décodeur Base64](https://acrafto.com/fr/encodeur-decodeur-base64/) ([Markdown](https://acrafto.com/fr/encodeur-decodeur-base64/index.md))
- Español (es): [Codificador y decodificador Base64](https://acrafto.com/es/codificador-base64-decodificador-online/) ([Markdown](https://acrafto.com/es/codificador-base64-decodificador-online/index.md))
- Italiano (it): [Encoder e decoder Base64](https://acrafto.com/it/encoder-decoder-base64-online/) ([Markdown](https://acrafto.com/it/encoder-decoder-base64-online/index.md))
- Português (pt): [Codificador e decodificador Base64](https://acrafto.com/pt/encoder-decoder-base64-online/) ([Markdown](https://acrafto.com/pt/encoder-decoder-base64-online/index.md))
- Nederlands (nl): [Base64 encoder en decoder](https://acrafto.com/nl/base64-encoder-decoder/) ([Markdown](https://acrafto.com/nl/base64-encoder-decoder/index.md))
- Polski (pl): [Koder i dekoder Base64](https://acrafto.com/pl/koder-dekoder-base64-online/) ([Markdown](https://acrafto.com/pl/koder-dekoder-base64-online/index.md))
- Română (ro): [Base64 encoder și decoder](https://acrafto.com/ro/codor-decodor-base64/) ([Markdown](https://acrafto.com/ro/codor-decodor-base64/index.md))
- Magyar (hu): [Base64 kódoló és dekódoló](https://acrafto.com/hu/base64-kodolo-dekodolo-online/) ([Markdown](https://acrafto.com/hu/base64-kodolo-dekodolo-online/index.md))
- Ελληνικά (el): [Κωδικοποίηση και αποκωδικοποίηση Base64](https://acrafto.com/el/base64-encoder-decoder/) ([Markdown](https://acrafto.com/el/base64-encoder-decoder/index.md))
- Български (bg): [Base64 енкодер и декодер](https://acrafto.com/bg/base64-enkoder-dekoder-onlain/) ([Markdown](https://acrafto.com/bg/base64-enkoder-dekoder-onlain/index.md))
- Hrvatski (hr): [Base64 koder i dekoder](https://acrafto.com/hr/base64-koder-dekoder/) ([Markdown](https://acrafto.com/hr/base64-koder-dekoder/index.md))
- Slovenščina (sl): [Base64 kodirnik in dekodirnik](https://acrafto.com/sl/base64-kodirnik-dekodirnik/) ([Markdown](https://acrafto.com/sl/base64-kodirnik-dekodirnik/index.md))
- Eesti (et): [Base64 kodeerija ja dekodeerija](https://acrafto.com/et/base64-teisendaja/) ([Markdown](https://acrafto.com/et/base64-teisendaja/index.md))
- Latviešu (lv): [Base64 kodētājs un dekodētājs](https://acrafto.com/lv/base64-kodetajs-dekodetajs/) ([Markdown](https://acrafto.com/lv/base64-kodetajs-dekodetajs/index.md))
- Lietuvių (lt): [Base64 koduotuvas ir dekoduotuvas](https://acrafto.com/lt/base64-koduotuvas-dekoduotuvas/) ([Markdown](https://acrafto.com/lt/base64-koduotuvas-dekoduotuvas/index.md))
- Svenska (sv): [Base64 encode och decode](https://acrafto.com/sv/base64-kodare-avkodare-online/) ([Markdown](https://acrafto.com/sv/base64-kodare-avkodare-online/index.md))
- Dansk (da): [Base64 encoder og dekoder](https://acrafto.com/da/base64-encoder-dekoder-online/) ([Markdown](https://acrafto.com/da/base64-encoder-dekoder-online/index.md))
- Suomi (fi): [Base64-kooderi ja -dekooderi](https://acrafto.com/fi/base64-kooderi-dekooderi/) ([Markdown](https://acrafto.com/fi/base64-kooderi-dekooderi/index.md))
- Norsk (no): [Base64-enkoder og -dekoder](https://acrafto.com/no/base64-enkoder-dekoder/) ([Markdown](https://acrafto.com/no/base64-enkoder-dekoder/index.md))
- Українська (uk): [Base64 кодер і декодер](https://acrafto.com/uk/base64-koder-dekoder-onlajn/) ([Markdown](https://acrafto.com/uk/base64-koder-dekoder-onlajn/index.md))
- Русский (ru): [Base64 кодировщик и декодировщик](https://acrafto.com/ru/base64-koder-dekoder/) ([Markdown](https://acrafto.com/ru/base64-koder-dekoder/index.md))
- Српски (sr): [Base64 enkoder i dekoder](https://acrafto.com/sr/base64-enkoder-dekoder-online/) ([Markdown](https://acrafto.com/sr/base64-enkoder-dekoder-online/index.md))
- Македонски (mk): [Base64 енкодер и декодер](https://acrafto.com/mk/base64-converter/) ([Markdown](https://acrafto.com/mk/base64-converter/index.md))
- Bosanski (bs): [Base64 koder i dekoder](https://acrafto.com/bs/base64-koder-dekoder/) ([Markdown](https://acrafto.com/bs/base64-koder-dekoder/index.md))
- Shqip (sq): [Base64 kodues dhe dekodues](https://acrafto.com/sq/kodues-dekodues-base64-online/) ([Markdown](https://acrafto.com/sq/kodues-dekodues-base64-online/index.md))
- Türkçe (tr): [Base64 kodlayıcı ve çözücü](https://acrafto.com/tr/base64-kodlayici-cozucu-online/) ([Markdown](https://acrafto.com/tr/base64-kodlayici-cozucu-online/index.md))
- 日本語 (ja): [Base64エンコード・デコード](https://acrafto.com/ja/base64-encoder-decoder/) ([Markdown](https://acrafto.com/ja/base64-encoder-decoder/index.md))
- 한국어 (ko): [Base64 인코딩 디코딩](https://acrafto.com/ko/base64-encoder-decoder/) ([Markdown](https://acrafto.com/ko/base64-encoder-decoder/index.md))
- العربية (ar): [ترميز وفك ترميز Base64](https://acrafto.com/ar/base64-encoder-decoder/) ([Markdown](https://acrafto.com/ar/base64-encoder-decoder/index.md))
- हिन्दी (hi): [Base64 एन्कोडर और डिकोडर](https://acrafto.com/hi/base64-encoder-decoder-online/) ([Markdown](https://acrafto.com/hi/base64-encoder-decoder-online/index.md))
- Bahasa Indonesia (id): [Base64 encode dan decode](https://acrafto.com/id/konverter-base64-online/) ([Markdown](https://acrafto.com/id/konverter-base64-online/index.md))
- Tiếng Việt (vi): [Mã hóa và giải mã Base64](https://acrafto.com/vi/base64-ma-hoa-giai-ma-online/) ([Markdown](https://acrafto.com/vi/base64-ma-hoa-giai-ma-online/index.md))
- ไทย (th): [เข้ารหัสและถอดรหัส Base64](https://acrafto.com/th/base64-encoder-decoder/) ([Markdown](https://acrafto.com/th/base64-encoder-decoder/index.md))
- עברית (he): [קידוד ופענוח Base64](https://acrafto.com/he/base64-encoder-decoder/) ([Markdown](https://acrafto.com/he/base64-encoder-decoder/index.md))
