Premium tools, free for everyone. Most run right in your browser.

OpenMultiURL

Developers

How to Encode Text to Base64 Online Using UTF-8

How to Encode Text to Base64 Online Using UTF-8 title on a coloured card

Hello becomes SGVsbG8= in Base64. But add a space after Hello, and you get a different result, even though that space is easy to miss in a text box. That's the detail I want you to catch before you encode text to Base64 online. I built Base64 Encoder and Decoder and tried these steps on my budget Android phone and laptop. I'll show you how I copy the result, check it, and avoid changing the text along the way.

How do I encode text to Base64 online?

I start with a short sample before pasting the text I actually need to convert. That gives me a known result to compare and makes it easier to spot a copying mistake. Open Base64 Encoder and Decoder and keep your original text somewhere you can compare it without retyping.

  1. Paste Hello into the input, with a capital H and no space or line break after it.
  2. Choose Encode to convert the text to Base64.
  3. Check that the output reads SGVsbG8=, then use Copy to copy the complete result.
  4. Put that result back into the input and choose Decode. I expect to get Hello back.
  5. Repeat with your own text, then test the encoded value in the system that requested it.

What I check before pasting

I check the destination's instructions first. Does it ask for standard Base64, Base64URL, or a particular text encoding? Those aren't cosmetic choices. A correct conversion can still be rejected if I give an application the wrong format. If the instructions only say Base64, I don't quietly remove padding or change the alphabet.

Tip from me: On my phone, I use Copy rather than dragging selection handles across a long result. Then I decode the copied value, so I'm checking what reached the clipboard, not just what appeared on screen.

What does Base64 change, and what does it keep?

I think of Base64 as a way to write bytes using a limited alphabet. It changes their representation, not their meaning. Standard Base64 uses uppercase letters, lowercase letters, digits, plus and slash. An equals sign can appear at the end as padding. The rules come from RFC 4648.

Text becomes bytes first

When I encode text, there are really two steps. First, the characters become bytes using a text encoding such as UTF-8. Then Base64 represents those bytes as text. This distinction explains why two encoders can disagree about the same visible word: they may have used different bytes before Base64 conversion even started.

I use UTF-8 for the text examples here. The first 128 UTF-8 characters match ASCII, while other characters can take multiple bytes. So an English sample such as Hello is useful for a quick check, but it doesn't prove that an encoder handles international text correctly.

And I don't describe the result as protected. Base64 needs no secret key to decode. It can make a value look unfamiliar, but that isn't privacy. If your purpose is to stop someone reading the content, converting it to Base64 doesn't solve your problem.

How can I check a Base64 result with examples?

I like examples where every input character is clear. In this table, the input contains only the visible text shown, without surrounding quotation marks or a final line break. Each result uses UTF-8 and standard Base64 with padding where needed.

My small reference set for checking text-to-Base64 conversion
Exact inputUTF-8 bytesStandard Base64
Hello5SGVsbG8=
Hello!6SGVsbG8h
cafe4Y2FmZQ==
café5Y2Fmw6k=
é2w6k=

The café row is the useful second test. Its final letter uses more than one UTF-8 byte, so counting visible letters isn't enough to predict the input size. I compare the entire encoded string, including its final equals sign, rather than deciding that a similar-looking result is close enough.

Why I decode the copied result

After encoding, I decode the clipboard contents and compare them with the original. That catches a missing character, an accidental extra space, or the wrong copied field. But a successful return trip doesn't prove that an API will accept the value. I still check its expected alphabet, padding rules, and text encoding.

How do I preserve Unicode and multiple lines?

I keep UTF-8 explicit whenever text contains accented letters or other non-ASCII characters. Base64 can represent their bytes perfectly well. The problem appears when something chooses the wrong text encoding before conversion, or uses the wrong encoding to read the decoded bytes afterward.

Why JavaScript btoa() can fail

I wouldn't pass arbitrary text straight to JavaScript's btoa(). It treats each input character as a byte and throws an error for characters with code points above 0xFF. Some accented letters don't trigger that error, which can make a limited test misleading. For Unicode text, I convert the text to UTF-8 bytes first. MDN's btoa() documentation explains that distinction.

  • For international text, I keep the text-to-byte encoding consistent.
    • I use UTF-8 before encoding.
    • I read the decoded bytes as UTF-8 too.
  • For multiline text, I preserve the intended input rather than flattening it.
    • I keep intentional blank lines and spaces.
    • I check whether the source includes a final line break.

I separate input line breaks from output wrapping. A line break in your original text belongs to the data. A line break inserted into the Base64 output is formatting. If you genuinely need to flatten the source, Remove Line Breaks can help, but I wouldn't use it just to make two outputs match.

Should I use standard Base64 or Base64URL?

I choose the variant by reading the receiving format's rules, not by guessing from where I plan to paste it. Base64URL replaces standard Base64's plus with a hyphen and its slash with an underscore. Padding is a separate decision governed by the format using it.

How I choose the representation the destination expects
Destination requirementMy choiceWhat I avoid
Standard Base64Standard alphabet, with required paddingReplacing characters just because the value will travel online
Base64URLURL-safe alphabet and the specified padding ruleAssuming every Base64URL format omits padding
JWT segmentBase64URL without paddingTreating it as ordinary padded Base64
Standard Base64 inside a URL parameterStandard Base64, then URL encoding where requiredAssuming the Base64 conversion also URL-encoded the value
JSON string valueThe Base64 variant requested by the applicationAssuming JSON itself chooses the Base64 variant

For a URL parameter, I keep Base64 encoding and URL encoding as separate steps. If the application expects standard Base64, changing it to Base64URL may be wrong. I can use URL Encoder for the URL-encoding step when required, but I don't change the underlying Base64 contract.

I apply the same care to data URLs. A Base64 string alone isn't a complete data URL, and encoding text doesn't supply the surrounding format automatically. I check the destination's required structure instead of treating every place that accepts text as interchangeable.

Should I keep equals signs and output line breaks?

I keep trailing equals signs unless the destination explicitly tells me to omit them. RFC 4648 requires padding in the general case, unless the specification using Base64 says otherwise. So my default isn't to trim the end until a value looks tidier. Those characters belong to the expected representation.

Padding isn't an error

Base64 converts groups of three input bytes into four output symbols. Padding completes the final group when needed. That's why Hello ends with an equals sign while Hello! doesn't. I don't add padding to every result either. A valid result can already have a complete final group.

For line breaks, I follow a similar rule: don't add them unless the receiving specification requires them. RFC 4648 says encoders must not insert line feeds without that direction. The familiar email convention of no more than 76 characters per line comes from MIME, described in RFC 2045. It isn't a universal Base64 rule.

Tip from me: I check whether a long result merely wraps visually in the text box before removing anything. A line appearing on screen isn't enough evidence that a line-break character was added to the copied value.

Why is Base64 output longer than my text?

I expect Base64 to increase size, not reduce it. Three input bytes become four encoded characters, so the result is about one-third larger before any added line breaks. Small inputs can have a more noticeable increase because of padding. Hello is five UTF-8 bytes but produces eight Base64 characters.

The useful comparison is input bytes against encoded output, not visible letters against output. With non-ASCII text, one visible character may use several UTF-8 bytes. I can use Character Counter to inspect text length, but I don't treat a character count as proof of its UTF-8 byte size.

  • For a destination with a size limit, I check the encoded value against that limit, not only the source text.
  • For a large input, I consider the extra output and the work involved in copying and checking it.
  • For repeated conversions, I prefer a repeatable local or application workflow over manual pasting.

I won't give you an invented maximum input size for an online converter. Practical limits depend on the tool, browser, and device. If a large paste becomes awkward to edit or verify, that's enough reason for me to move the task into a more controlled workflow rather than keep retrying blindly.

What mistakes should I check when Base64 fails?

When an output fails, I check the original input before changing the encoded result. Editing Base64 by hand can hide the real problem. My first goal is to find where the bytes or format stopped matching the destination's expectations.

  1. Compare the source text. I look for leading spaces, trailing spaces, tabs, and a final line break.
  2. Confirm UTF-8. If accented text comes back wrong, I check the text encoding on both sides.
  3. Check the variant. I compare standard Base64 against Base64URL requirements rather than swapping symbols at random.
  4. Check padding and wrapping. I follow the receiving specification instead of another tool's appearance.
  5. Decode the copied result. I compare the recovered text with the source before testing the destination again.

I also check whether I encoded an already encoded value. If decoding once gives me another Base64-looking string instead of my original sentence, I inspect the workflow for an extra conversion. I don't automatically decode repeatedly, because the original text might legitimately resemble Base64.

If the value belongs inside JSON, I check the surrounding document separately with JSON Formatter and Validator. Correct Base64 doesn't repair a broken JSON document. Separating those checks helps me avoid blaming the encoder for an error in the container.

Is an online Base64 encoder right for my text?

I use an online converter for short examples, documentation samples, and one-off checks with non-sensitive text. It's convenient when I need to see the original and encoded forms together. But convenience doesn't establish that a page is suitable for confidential material.

What I check before using sensitive input

I check how the page processes input, whether third-party scripts run, and whether sharing features place input in a URL. A browser-side processing claim alone doesn't answer all those questions. I also follow any rules that apply to the data. If I can't establish that the workflow is approved, I use a suitable local environment instead.

  • For public examples, I use obvious sample text such as Hello or café.
  • For real passwords, API keys, or confidential records, I avoid casual online pasting.
  • For repeated work, I document UTF-8, the Base64 variant, padding, and line-break rules in the application workflow.

My preference is simple: use the browser to understand and verify a conversion, then put recurring production work where its rules can be kept consistent. And I treat the encoded output with the same care as the original. Copying a secret into Base64 doesn't make it safe to share in a screenshot or message.

Questions people ask

How do I convert a string to Base64?

I convert the string to bytes using a stated text encoding, normally UTF-8 for this workflow, then encode those bytes as Base64. In Base64 Encoder and Decoder, I paste the text, choose Encode, and copy the result. I decode the copied value afterward to check that it returns my exact original text.

Does Base64 support Unicode and accented characters?

Yes, Base64 can represent the bytes used for Unicode text. I use UTF-8 to turn the characters into bytes first, then apply Base64. On the way back, I decode Base64 and read the recovered bytes as UTF-8. Using a different text encoding on either side can change the result or produce incorrect text.

Why does JavaScript btoa() fail on some characters?

I don't treat btoa() as a general text encoder. It expects each input character to represent a byte and throws an error for code points above 0xFF. For Unicode text, I first obtain UTF-8 bytes and then encode those bytes. A test that works with plain English doesn't establish that direct btoa(text) handles all text.

Should I include the equals signs at the end of Base64?

I keep them unless the receiving format explicitly says to omit padding. RFC 4648 requires padding in the general case, but formats can define a different rule. JWT, for example, uses Base64URL without padding. I also don't add equals signs to a result that already has a complete final group.

Does Base64 encoding make text secure or encrypted?

No. I treat Base64 as a reversible representation, not a security measure. Anyone with the encoded value can decode it without a secret key. That means an encoded password or API key is still sensitive. I don't share it publicly or paste it into an unapproved tool just because it looks unreadable.

How do I encode multiple lines of text without changing them?

I paste the original text with its intended spaces and line breaks intact, then encode it using UTF-8. After copying the result, I decode it and compare the recovered text with the source. I keep input line breaks separate from output wrapping, and I don't remove either without checking the destination's requirements.

What to do next

Start with Hello in Base64 Encoder and Decoder. Choose Encode, check for SGVsbG8=, copy it, and decode that copied value back to Hello. Then repeat with your own non-sensitive text, keeping spaces and line breaks exactly as intended. I use UTF-8 and check the destination's rules before changing the alphabet, padding, or wrapping. If the result fails, I compare the original bytes and format expectations rather than editing the encoded string by guesswork. And if your text contains a secret, stop and choose an approved workflow first. Base64 changes how text is represented, not who can read it.

Sources I checked

Tools from this guide

Keep reading