---
title: "How to encode and decode Base64 online | ToolSugar"
description: "Encode text or a file to Base64, decode it back, and choose the URL-safe alphabet when the result goes into a link or a token."
canonical: https://toolsugar.com/blog/how-to-encode-and-decode-base64
image: https://toolsugar.com/og.png
---

# How to encode and decode Base64 text and files

Updated 2026-11-09

To encode text to Base64, convert its bytes into a string of 64 safe characters. Base64 Encoder and Decoder does this in your browser, in both directions, and it can also turn a file into a Base64 string. Nothing is uploaded. This guide shows the steps and explains URL-safe output and padding.

[Open Base64 Encoder and Decoder](https://toolsugar.com/tools/base64-encoder)

## Encode or decode Base64 in four steps

The tool has three modes. Pick the one that matches what you hold.

1. Pick Text to Base64, Base64 to text, or File to Base64.
2. Type or paste your input, or choose a file.
3. Switch on the URL-safe alphabet if the result goes into a URL or a JWT.
4. Read the Result box and press Copy.

## What Base64 is for

Base64 lets binary data travel through systems that only handle text. Email attachments, data URLs in CSS and HTML, and API fields that carry small images all use it. Every three bytes become four characters, so the output is about a third larger than the input.

Large files make a very long string, so keep file encoding for small images and fonts. A data URL in CSS or HTML puts the encoded string after a prefix such as data:image/png;base64, and the browser draws it without a second request. That saves a round trip for a tiny icon but bloats the page for a large photo, so a separate image file wins past a few kilobytes.

## URL-safe Base64 and padding

Standard Base64 uses + and /, which have special meaning inside a URL. The URL-safe alphabet replaces them with - and \_, and it drops the trailing = padding. JWTs use this form.

When you decode, the tool accepts either alphabet, with or without padding. You do not need to fix the string first.

## Why decoding shows garbage or an error

Not every Base64 string holds text. If the bytes are an image or a zip file, decoding them as UTF-8 gives broken characters, and the tool says the bytes are not text. Use File to Base64 for the other direction and save binary data in a file instead.

A missing character or a symbol outside the Base64 alphabet will also break decoding. Copy the string again from the source. Line breaks inside long Base64 are common in email and certificates. The tool ignores spaces and line breaks, so paste a wrapped string exactly as you have it.

## Questions

### Does Base64 keep my data secret?

No. Anyone can decode it in seconds. Use encryption when the data must stay private.

### Why does the Base64 output end with = signs?

Padding fills the last group so the length is a multiple of four. One or two = signs at the end are normal.

### Can I encode accents and emoji?

Yes. The tool reads text as UTF-8, so characters outside basic English survive a round trip.

[Open Base64 Encoder and Decoder](https://toolsugar.com/tools/base64-encoder)

## Related guides

- [How to URL encode and decode a string](https://toolsugar.com/blog/how-to-url-encode-a-string)
- [How to decode a JWT and read its claims](https://toolsugar.com/blog/how-to-decode-a-jwt)
- [How to make a QR code from a link or text](https://toolsugar.com/blog/how-to-make-a-qr-code)
- [How to make a favicon from an image](https://toolsugar.com/blog/how-to-make-a-favicon)
