ToolHub

Base64 Encoder/Decoder

Encode and decode Base64 text

Plain text

Base64

Overview

Encode and decode Base64 strings instantly

Base64 is a way to represent binary data using only 64 ASCII characters: A to Z, a to z, 0 to 9, plus, slash, and equals for padding. The point is to take data that might contain arbitrary bytes (images, file contents, encrypted blobs) and encode it as plain text that can travel safely through systems designed for text only: email, JSON payloads, URL parameters, XML attributes, and source code.

ToolHub Base64 Encoder converts text to Base64 and back. It handles UTF-8 properly, so emoji and non-Latin scripts round trip correctly. Everything happens in your browser.

Step-by-step

How to use Base64 encode and decode

  1. 1

    Pick a mode

    Encode converts plain text to Base64. Decode does the reverse, converting Base64 back to readable text.
  2. 2

    Type or paste your input

    Drop your text or Base64 into the input panel. The output updates as you type.
  3. 3

    Copy or swap

    Click copy to grab the result. The swap button reverses input and output, useful for round-tripping.

Background

What Base64 actually does

Base64 takes 3 bytes (24 bits) of input and encodes them as 4 ASCII characters (each carrying 6 bits). The output is always about 33 percent larger than the input. If the input length is not a multiple of 3, padding equals signs are added at the end to make the output length a multiple of 4.

Why “not encryption” matters

Base64 is encoding, not encryption. Anyone can decode a Base64 string back to its original. It hides nothing. Putting a password in Base64 in code or in a URL is exactly as insecure as putting the plain text. If you need privacy, use encryption (AES, libsodium, or HTTPS), not Base64.

UTF-8 and emoji

Standard Base64 only handles bytes. To encode text, you first need to convert the text to bytes using UTF-8. Our encoder does this automatically, so you can encode emoji, Hindi, Chinese, Arabic, or any other text without corruption.

Use cases

When to use Base64

Embedding images in CSS or HTML

Use data URIs (data:image/png;base64,...) to inline small images directly in stylesheets or markup.

Email attachments

MIME email standards use Base64 to send binary attachments through text-only email infrastructure.

JSON binary fields

JSON does not have a native binary type. Encode binary data as Base64 strings to include it in API payloads.

Authentication tokens

JWT tokens use Base64URL (a slight variant) to encode their three parts: header, payload, signature.

Storing files in databases

Some legacy systems store small binary files as Base64 text columns, which is simple if not space-efficient.

URLs with binary data

Pass small binary blobs through URL parameters by Base64-encoding them first.

Tips and best practices

  • Base64 increases size by 33 percent. For large files, gzip first then Base64.
  • Avoid Base64 in URLs unless necessary. Plus and slash characters can cause problems. Use Base64URL variant if you must.
  • Never use Base64 for security. It is encoding, not encryption.
  • When decoding fails, the input is malformed. Check for missing padding or unexpected characters.
  • Newlines in Base64 output are decorative only and are ignored by decoders.

Common questions

Why is the encoded output larger than my input?

Base64 represents 3 bytes as 4 characters, a 33 percent size increase. Plus padding can add up to 2 more characters at the end. This overhead is the cost of guaranteed safe text transport.

Why does my decoded text have garbage characters?

The original encoder might have used a different encoding (Latin-1, Windows-1252) instead of UTF-8. Our decoder uses UTF-8 which is the modern standard. Mismatched encodings produce garbage on round-trip.

What is Base64URL?

A variant of Base64 designed for URLs. It replaces plus with dash, slash with underscore, and removes padding equals signs. Used in JWT tokens and modern web APIs.

Can I encode files?

The current tool encodes text. To encode an arbitrary file as Base64, drop it into a tool that reads files (or open the devtools console and use FileReader API).

100% private

Privacy and security

Encoding and decoding are local operations using browser built-in btoa, atob, TextEncoder, and TextDecoder. Nothing is sent over the network.

Related tools

Frequently asked questions

What is Base64 used for?

Base64 encodes binary data as ASCII text. It's commonly used to embed images in CSS/HTML, transmit binary data over email, and encode data in URLs.

Does it support Unicode?

Yes. We encode UTF-8 properly so emoji and non-Latin scripts round-trip correctly.