Skip to content
Useful tools

Base64: how to encode and decode online in simple terms

AuthorEditorial team 9-07-2026, 00:09 276
Base64: how to encode and decode online in simple terms
Advertising
In brief
  • Base64 is a way to represent any binary data as text made up of 64 safe characters (A–Z, a–z, 0–9, ‘+’, ‘/’).
  • It is needed where the channel understands only text: emails with attachments, JSON, XML, data-URI in HTML and CSS.
  • Encoding and decoding are reversible lossless operations; it is not encryption and not compression.
  • The main downside is an increase in size of about 33%, so Base64 is used cautiously for large files.

You have probably encountered long strings like SGVsbG8sIHdvcmxkIQ== in emails, configs, or the source code of pages. This is Base64 — a universal 'translator' between binary data and plain text. In this article, we will explain in simple terms what Base64 encoding is, why it was created, where it is used every day, and how to quickly encode or decode a string online without installing software.

Base64 Encoder
Encode and decode Base64 online — for free
Open the tool →

What is Base64 and how does it work

Base64 is an encoding scheme that translates an arbitrary set of bytes into a string of 64 printable characters. The alphabet includes uppercase and lowercase Latin letters, digits from 0 to 9, and two additional symbols '+' and '/'. The principle is simple: the original data is split into groups of 3 bytes (24 bits), and then these 24 bits are sliced into 4 parts of 6 bits each. Each 6 bits gives a number from 0 to 63 — which is then replaced by a single character from the table. If there are not enough bytes at the end to complete the trio, the result is padded with the '=' symbol, which is called padding. That is why encoded strings often end with one or two equal signs.

It is important to understand: Base64 does not hide or protect information. Anyone can decode a string back in seconds. It is simply a 'packaging' safe for transmission, not a lock.

Why Base64 is needed: real tasks

Many communication systems are initially designed only for text. If you send 'raw' bytes of an image or archive through such a channel, they may get distorted: control characters, line breaks, and non-standard codes can corrupt the data. Base64 solves this problem by converting any bytes into safe text that passes through without loss.

Typical use cases:

  • Email. The MIME standard encodes attachments — photos, PDFs, documents — specifically in Base64 to ensure they reach the recipient.
  • Data-URI. Small icons and images can be embedded directly in HTML or CSS with a line like data:image/png;base64,..., reducing the number of requests to the server.
  • API and JSON. In web requests, binary fields (avatar, signature, token) can be conveniently transmitted as text within JSON or XML.
  • Storage of keys and certificates. PEM format, authorization tokens, and digital signatures are often represented in Base64.

How to encode and decode Base64 online

The fastest way is to use an online tool directly in your browser. The steps are almost the same everywhere:

  1. Paste the source text or upload a file in the input field.
  2. Choose the operation — 'Encode' (text → Base64) or 'Decode' (Base64 → text).
  3. Specify the encoding if you are working with Cyrillic: usually it's UTF-8, otherwise Russian letters will be decoded incorrectly.
  4. Copy the ready result with one click.

If you are working in the terminal, it's even simpler. In Linux and macOS, the command echo -n "Привет" | base64 will encode the string, and base64 -d will perform the reverse operation. In the browser, developers use built-in functions btoa() и atob(), and in Python — the module base64. The online service is convenient because it requires no installation and is suitable for one-time tasks.

Limitations and frequent errors

Base64 has some peculiarities to keep in mind. First, the size of the data increases by about 33%: every 3 bytes are turned into 4 characters. This is not noticeable for small icons, but embedding a large photo in a page via data-URI is a bad idea, as it will bloat the HTML and slow down loading.

Second, there are several dialects. Standard Base64 uses '+' and '/', but these characters are problematic in URLs, so a variant called Base64URL was created, where they are replaced with '-' and '_'. If the alphabets are mixed up, decoding will result in an error. Third, when working with Cyrillic, matching the encoding is critical: a string encoded in UTF-8 must also be decoded as UTF-8, otherwise the output will be a 'mash' of characters.

Base64 is not encryption

The most common misconception is to consider Base64 a means of protection. This is not the case. Encoding is reversible and public: the algorithm is known, no key is needed, and anyone can decode the string. If you need to hide data, use real encryption, such as AES, and use Base64 only as a transport wrapper — often on top of the encrypted result, to safely transmit it as text.

Frequently Asked Questions

Is Base64 encryption?
No. It is a keyless encoding: the string can be easily decoded back. Separate encryption is needed to protect data, and Base64 only helps to transmit bytes in text form.

Why does a Base64 string end with ‘=’?
The ‘=’ sign is padding. It complements the data when its length is not a multiple of three bytes. One or two equal signs at the end indicate how many bytes were in the last incomplete group.

How much does the size of the data increase?
Approximately by 33%: every 3 original bytes are turned into 4 Base64 characters. Therefore, encoding large files in Base64 is not cost-effective; it's better to transfer them directly.

Why is Cyrillic decoded into unreadable characters?
Most likely, the encoding did not match. Russian text needs to be encoded and decoded in the same encoding (usually UTF-8), otherwise the bytes are interpreted incorrectly.

Base64 Encoder
Encode and decode Base64 online — for free
Open the tool →

Updated: July 9, 2026. Edition of MegaInet.art.

How useful is the material?Evaluation helps us choose topics
00 ratings
Analytics

Story statistics

276views
0comments
5min read
5 / 20rank among section stories

Read more often than 79% of stories in this section.

Discussion

No one has spoken yet — be the first.

Comments are written by participants Log in to the site — it's free and takes a minute. Comments are moderated.
Log in
Advertising

What searches this page answers