Back to blog

Base64EncodingDeveloper ToolsOnline Tools

Base64 Encoding and Decoding: What It Is and How to Convert Text Online

Learn what Base64 is, where it's used (JWT, data URIs, APIs), how to convert text online in seconds, and why Chinese text sometimes turns into garbled output.

If you have ever debugged an API, inspected a token, or copied a small image from a web page, you have probably seen a string that looks like SGVsbG8sIOm4rem4rQ==. It looks like gibberish, but it is really just text in a different representation, and that representation is called Base64. This article explains how Base64 encoding and decoding work with concrete examples, where they are used, and what usually goes wrong, then walks through the whole flow with an online converter.

What Is Base64, in One Paragraph

Base64 is an encoding scheme that represents binary data using 64 printable characters. It splits every 3 bytes (24 bits) into four 6-bit groups and maps each group to one character; when the byte count is not a multiple of 3, = padding is added. The specification lives in RFC 4648.

An example is the fastest way to see it. Hello, 鸭鸭 is encoded as UTF-8 bytes first, then converted to Base64:

text
Hello, 鸭鸭
→ SGVsbG8sIOm4rem4rQ==

Anyone who receives SGVsbG8sIOm4rem4rQ== can decode it back to the original text. Base64 is encoding, not encryption: it does not hide content, it only changes how it is represented. That distinction is often misunderstood.

Why Base64 Exists

Network transport and many text-based formats only accept printable characters. Binary data such as images, certificates, and tokens can break or get corrupted when placed directly inside JSON, URLs, or emails. Base64 turns binary data into plain text so it can travel safely through those channels. Common use cases:

Use case How it works
JWT / tokens The JWT header and payload are Base64Url-encoded JSON
data URIs Small images are inlined in HTML/CSS, e.g. data:image/png;base64,...
API fields Binary or special-character content is carried inside JSON fields
Email attachments MIME uses Base64 to transmit attachment content

Convert Text Online in Three Steps

An online converter is the fastest path and needs no installation:

  1. Open the Base64 encoder/decoder, paste the text
  2. Choose "Encode" or "Decode", the result updates in real time
  3. Click "Copy" to take the result with you

The tool supports Chinese, English, numbers, and common special characters. All encoding and decoding happens locally in the browser, so your content never leaves your machine, which is handy when you need to process text you would rather not upload.

Why Chinese Text Turns into Garbled Output: UTF-8 Is the Key

Chinese characters convert correctly only when the text is first encoded to bytes as UTF-8 and then Base64-encoded. Most garbled-output problems come from mismatched character sets: the same sentence produces different bytes under different charsets, hence different Base64 results, and decoding with the wrong charset yields mojibake.

Operation Common mistake Correct approach
Encoding Chinese Converting with an old tool that is not UTF-8-aware Encode bytes as UTF-8 first, then Base64
Decoding Restoring bytes without considering the charset Decode bytes back to text as UTF-8

A related trap is URL-safe Base64 (Base64Url): JWT and similar formats use - and _ instead of + and /, and drop the = padding. Before decoding a JWT segment with a regular Base64 decoder, you usually need to substitute the characters first.

Why Decoding Fails: The Most Common Causes

When the tool reports that it cannot decode, the cause is usually one of these:

  • Truncated input: the string was cut off when copied, so the = padding is missing. Complete it and try again.
  • Foreign characters: newlines, spaces, or URL-encoded %xx are not part of the Base64 alphabet. Clean them up first; if the content is %xx-style, run it through the URL encoder/decoder first.
  • Base64Url mix-up: JWT uses - and _. Substitute them back to + and / before decoding.

If an API response contains JSON fields you cannot read, lay the structure out with the JSON formatter and then decode the specific field. We also wrote a full walkthrough for debugging broken API JSON that covers similar situations end to end.

FAQ

Is Base64 encryption?

No. Base64 does not hide content; anyone can decode it back to the original. It is only a different representation. For confidential data, use a real encryption algorithm, such as the AES encrypt/decrypt tool.

Can it encode files?

The current tool targets text. Encoding images or large files consumes significant memory, so for those use a local command-line tool (e.g. base64 file.png) or a dedicated file utility.

Does my data get uploaded to a server?

No. All encoding and decoding runs locally in the browser, which makes it suitable for text you do not want to upload.

Can I decode a JWT segment directly?

JWT uses Base64Url encoding, so pasting a segment in directly may fail. Substitute - to + and _ to / first, and the payload becomes decodable.

Summary

Base64 is an encoding scheme every developer runs into: the idea takes one paragraph to explain, the use cases concentrate around JWT, data URIs, and API fields, and the usual pitfalls are the UTF-8 charset and padding. Next time you see a long string you do not recognize, do not guess. Open the Base64 encoder/decoder, paste it in, and you will know what it says in ten seconds.

On this page