Developer Tools

How to Encode and Decode Base64 Text Without Data Loss

Understand Base64 padding, UTF-8 and URL-safe output with exact examples, then diagnose invalid characters, missing data and binary-versus-text errors.

By the Criza Labs team · Updated · 6 min read

Key takeaways

  • Base64 is a reversible encoding, not encryption or a way to hide credentials.
  • CrizaTools encodes text as UTF-8 and can generate standard padded or URL-safe unpadded output.
  • The decoder displays UTF-8 text, so a Base64 image or archive is not a supported file-download workflow.

Base64 represents bytes using a restricted text alphabet so data can pass through systems that expect text. Use a text encoder or decoder when inspecting an encoded message, configuration value or development sample, and check the required alphabet and character encoding before copying the result into another system.

Before you start

Identify what the input represents. An encoded greeting, an image attachment and a JWT segment can all contain Base64-like text, but they are not the same task. This tool converts text to Base64 and decodes bytes as UTF-8 text; it does not provide a general attachment viewer or a binary-file downloader.

Check whether the receiving system expects standard Base64 or the URL-safe variant. Standard output uses + and /, while the URL-safe alphabet substitutes - and _. CrizaTools also omits trailing padding in its URL-safe output. The two alphabets and padding rules are specified in RFC 4648, checked 16 November 2026.

Inputs stay in your browser; CrizaTools does not upload the text for conversion. Base64 itself provides no secrecy, so do not use it as protection for credentials or personal data. Work with an artificial sample when explaining a workflow and keep a copy of the original text if exact spaces or line breaks matter.

Step by step with CrizaTools

  1. Open Base64 encode and decode. Under Direction, choose Text → Base64 for encoding or Base64 → text for decoding. The page initially contains an example; replace it with your own input.
  2. Paste into the left-hand box, labelled Text or Base64 according to the direction. The right-hand box is read-only output. Conversion happens automatically as the input changes.
  3. When encoding, select URL-safe (- and _, no padding) only when that is the representation required by your next step. The checkbox is not shown in decode mode because the decoder accepts both alphabets.
  4. Read the status beneath the boxes. A successful conversion shows input and output character counts; an unsuccessful decode explains invalid characters, impossible length or bytes that cannot be displayed as UTF-8 text.
  5. Select Copy result to copy only the output. Use Swap direction when you want to put the current output into the input and reverse the conversion; simply selecting another Direction does not first replace your input with the previous result.
  6. Compare the round-trip result with your original when checking a sample. Select Clear to empty the input, after preserving any text you need elsewhere. There is no file picker or download button in this interface.

Two worked examples

Example 1: encoding a short city name. Select Text → Base64, leave URL-safe unticked, and enter exactly Pune, with no final newline. The exact standard result is:

UHVuZQ==

The status reports 4 characters in, 8 out. The original contains four UTF-8 bytes. The standard encoded-length calculation is 4 × ceil(byte count/3), giving 4 × ceil(4/3) = 8 characters including padding. The two = characters complete the final group; they are not part of the city name.

Select Swap direction and the input becomes UHVuZQ==; the output becomes exactly Pune, with 8 characters in, 4 out. If you re-encode Pune with URL-safe selected, the result is UHVuZQ, because this tool removes the two padding characters. The decoder accepts that representation too.

Example 2: a greeting emoji and URL-safe output. Enter the single emoji 🙏 in Text → Base64. It is one Unicode code point encoded as four UTF-8 bytes. Standard output is exactly 8J+Zjw==; with URL-safe selected, it becomes exactly:

8J-Zjw

The standard status is 1 characters in, 8 out, while URL-safe shows 1 characters in, 6 out. The + changes to - and the two padding characters disappear. Decode either representation to recover the same emoji.

After swapping to decode, the displayed output count is 2, even though you see one emoji. The component counts input by Unicode code points but output using JavaScript string length, which uses two units for this character. That difference is a display-count convention, not a second emoji or evidence of data corruption. Compare the actual text when validating the round trip.

Limits and what to watch for

The input limit is 10 MB, with 1 MB equal to 1,048,576 bytes. The check measures the UTF-8 size of the supplied input in either direction. Encoded text can therefore reach the input ceiling even when its decoded content would be smaller; character counts and byte counts are not interchangeable for Indian scripts or emoji.

Base64 works on byte groups, not visible characters. Hindi, Gujarati, currency symbols and emoji are first converted into UTF-8 bytes, so their encoded lengths cannot be predicted by counting displayed letters alone. CrizaTools’s implementation performs this conversion before encoding and uses a strict UTF-8 decoder when reading the result.

The decoder removes whitespace, accepts the standard and URL-safe alphabets, and restores omitted padding when the remaining length permits it. It rejects characters outside those alphabets and a remaining length that is one more than a multiple of four. This tolerance does not prove the source is complete: a truncated value can sometimes still decode to text, so compare the full source and expected content.

A data:image/...;base64, prefix is not part of the Base64 payload. Removing it may get past a character error, but image bytes still do not become a readable text document. The binary-data message means the bytes failed strict UTF-8 decoding; a text value in another character encoding can produce the same message, so it is not definitive file-type detection.

Base64 does not compress the content or establish authenticity. RFC 4648 warns that encoding does not protect sensitive information; checked 16 November 2026 in its security considerations. Do not alter a signed payload or secret merely to make its representation look tidier without understanding the consuming protocol.

Common mistakes

  • Encoding confidential text to “secure” it: use an appropriate security mechanism; Base64 is readable after decoding.
  • Pasting a data-URL prefix into the decoder: identify the actual payload and whether it represents text or a file.
  • Choosing a different Direction without moving the output: use Swap direction for a round-trip check.
  • Adding padding to fix every error: check for missing content and the correct alphabet first.
  • Comparing emoji counts with visible glyphs: distinguish the actual recovered text from the interface’s count units.
  • Treating a readable decode as proof of completeness: verify against the source and expected message.

Questions and answers

Is Base64 encryption?

No, it is a reversible representation of bytes and does not require a secret key to decode. RFC 4648 explicitly cautions against treating it as protection for sensitive information; checked 16 November 2026 in its security section.

Why does Base64 sometimes end in equals signs?

Standard padded output uses trailing equals signs to complete its final four-character group. CrizaTools omits that padding in URL-safe mode and accepts either padded or unpadded input when decoding.

Can I encode Hindi text or emoji without garbling it?

CrizaTools converts the input into UTF-8 bytes before Base64 encoding. Decode the complete result back as UTF-8 to recover the text, and check the actual content rather than assuming visible characters map one-to-one to bytes.

Why does the decoder say my input contains binary data?

The decoded bytes could not be interpreted as valid UTF-8 text. They might represent a file or text in another encoding; this interface does not identify the file format or offer a binary download.

Should I use standard Base64 or URL-safe Base64?

Use the variant required by the protocol or application receiving the value. This tool’s URL-safe setting replaces plus and slash with hyphen and underscore and removes padding; changing the representation without checking the receiver can cause avoidable errors.

Sources

Inspect the representation with Base64 encode and decode, or use the JWT decoder for a synthetic token whose header and claims you want to read together.

Free tools for this

PDF & image

Base64 Encode & Decode

Encode text to Base64 or decode Base64 back to text, with full UTF-8 for emoji and Indian scripts and a URL-safe option.

PDF & image

JSON Formatter

Format, validate and minify JSON in your browser. Shows the line and column of any error, sorts keys and copies or downloads the result.

PDF & image

JWT Decoder

Decode a JSON Web Token in your browser to read its header and claims, with issued and expiry times in your time zone.

More guides

Free desktop app from Criza Labs

Bill every day? Get CrizaVoise free

GST invoices, thermal receipts, stock and payments in one offline app for Windows, Linux and macOS. No subscription, no sign-up, no ads, and your data stays on your computer.

  • 58 mm and 80 mm thermal printing
  • UPI QR on every invoice, WhatsApp sharing
  • Open source (Apache 2.0), English, Hindi, Gujarati and more
The CrizaVoise dashboard with quick bill and new invoice buttons, stock alerts and sample figures