UseToolSuite UseToolSuite

Base64 Encoder / Decoder

Encode text to Base64 or decode Base64 back to text instantly. All processing happens locally in your browser — nothing is sent to a server.

100% Client-Side No File Size Limit Zero Server Uploads Instant Execution
Last updated

Base64 Encoder / Decoder encodes and decodes locally, so nothing you paste is ever transmitted. It's one of the free Encoding & Decoding Tools on UseToolSuite. Use it below, then scroll down for a step-by-step guide, answers to common questions, and related tools.

Drop any file here to encode as Base64, or click to select

What is Base64 Encoder / Decoder?

Base64 Encoder / Decoder converts plain text into Base64-encoded strings and back again. Base64 is a binary-to-text encoding scheme that represents binary data using 64 ASCII characters (A–Z, a–z, 0–9, +, /), making it safe for transmission over text-based protocols like HTTP, SMTP, and JSON. This tool handles encoding and decoding instantly with full Unicode and UTF-8 support.

When to use it?

Use the Base64 tool when you need to embed binary data — such as images, fonts, or certificates — directly into HTML, CSS, or JSON files. It’s essential when working with APIs that require Base64-encoded payloads, decoding authentication tokens, or preparing MIME email attachments. It’s also useful for debugging encoded values you encounter in logs, URLs, cookies, and configuration files.

Typical tasks developers solve with it:

  • Embed small images as data URIs directly in HTML and CSS
  • Encode API credentials for HTTP Basic Authentication headers
  • Decode JWT token segments for rapid visual inspection
  • Convert binary certificate data (PEM) into a text-safe format

Step-by-step: how Base64 encoding works

Base64 converts every 3 bytes of input into 4 ASCII characters. First, the bytes are concatenated into a 24-bit sequence. That sequence is split into four 6-bit groups, and each group maps to one of the 64 characters in the Base64 alphabet. If the input length isn’t divisible by 3, padding characters (=) are appended. For example, the text Hi (2 bytes) yields SGk= — the trailing = signals one byte of padding.

Base64 vs URL encoding vs Hex encoding

FeatureBase64URL EncodingHex
Size overhead~33%Varies (up to 3×)100%
URL-safeNo (use URL-safe variant)YesYes
Human readableNoPartiallyNo
Best forBinary data in textQuery parametersHashes, debugging

Choose Base64 when embedding binary content like images or certificates in JSON, HTML, or email. Use URL encoding for query-string parameters and form data. Use hexadecimal for hash outputs, color codes, and low-level debugging where byte-level inspection matters.

Base64 in different programming languages

In JavaScript, use btoa() / atob() for Latin-1 text, or Buffer.from(text).toString('base64') in Node.js for full UTF-8 support. Python ships the base64 module with b64encode() and b64decode(). Go provides encoding/base64 with StdEncoding and URLEncoding variants. Java offers java.util.Base64 with getEncoder() and getDecoder(). Each language handles UTF-8 input slightly differently, so always confirm the character encoding matches the producer’s expectations before decoding.

How to Use This Tool

  1. 1

    Select Mode

    Choose whether you want to encode plain text to Base64 or decode an existing Base64 string back to text using the toggle buttons.

  2. 2

    Paste Data

    Paste your text or Base64 string into the input area. The tool will automatically detect if the input appears to be valid Base64.

  3. 3

    Copy Result

    Click the copy button or the "Copy Share Link" button to share the encoded/decoded state securely.

How helpful was this tool?

Click to rate

Key Concepts

Essential terms and definitions related to Base64 Encoder / Decoder.

Base64 Encoding

A binary-to-text encoding scheme that represents binary data using a set of 64 ASCII characters (A-Z, a-z, 0-9, +, /). It is used to safely transmit binary data through text-only channels such as email (MIME), JSON payloads, and HTML data URIs. Base64 increases the data size by approximately 33%.

Data URI

A URI scheme (data:[mediatype][;base64],data) that allows embedding small files directly in HTML or CSS as inline text instead of referencing an external URL. Commonly used for small images, fonts, and icons to reduce HTTP requests. The Base64-encoded content is placed directly in the src attribute or CSS url() function.

Padding Characters (=)

Base64 output must always be a multiple of 4 characters. When the input byte count is not divisible by 3, one or two = padding characters are appended to the output to reach the required length. URL-safe Base64 variants often strip these padding characters, which must be restored before standard decoding.

Frequently Asked Questions

Can I encode binary files like images with this tool?

This tool is designed for text-to-Base64 encoding. For encoding binary files such as images or PDFs, you would need to use a file-based Base64 encoder that reads raw bytes, which this text-only tool does not support.

What character encoding does this tool use?

The tool uses UTF-8 encoding by default, which supports all Unicode characters including emojis, accented characters, and non-Latin scripts. This ensures broad compatibility with modern web standards.

Is the output URL-safe Base64?

The tool produces standard Base64 output using the characters A-Z, a-z, 0-9, +, and /. If you need URL-safe Base64 (which replaces + with - and / with _), you can manually substitute those characters in the output.

Can I decode Base64 strings that contain line breaks?

Yes. The decoder automatically strips whitespace and line breaks from the input before decoding, so you can paste Base64 content that has been wrapped across multiple lines.

What does the = padding at the end of a Base64 string mean?

Padding indicates that the original input length was not divisible by 3 bytes. One = means the final group encoded 2 bytes; two == means it encoded only 1 byte. Decoders use the padding to know exactly how many bytes to reconstruct, although many modern decoders also accept unpadded input.

Why does my decoded Base64 output look garbled?

Garbled output usually means the original data was not UTF-8 text — it may be binary data (an image or archive), text in a legacy encoding like ISO-8859-9, or a double-encoded string. Try decoding twice for double-encoded values, and remember that decoding binary data to text will always produce unreadable characters.

Troubleshooting & Technical Tips

Common errors developers encounter and how to resolve them.

InvalidCharacterError: Padding error — missing = character

The length of a Base64 output must always be a multiple of 4. Missing padding characters (= or ==) will cause the decode operation to fail. The atob() function expects strict padding; if your Base64 string comes from a URL-safe format where padding has been stripped, add the missing = characters before decoding: str.padEnd(str.length + (4 - str.length % 4) % 4, "="). Use this tool to quickly verify whether your input contains valid padding.

DOMException: UTF-8 character encoding mismatch with btoa()

JavaScript's btoa() function only supports the Latin-1 (ISO-8859-1) character range. Non-ASCII characters such as accented letters, CJK characters, or emojis cannot be encoded directly with btoa() and will throw an InvalidCharacterError. The solution is to first convert the text to a UTF-8 byte sequence: btoa(unescape(encodeURIComponent(text))). For decoding, apply the reverse: decodeURIComponent(escape(atob(encoded))). This tool handles this conversion automatically.

URL-safe Base64 vs Standard Base64 format confusion

Standard Base64 uses the +, /, and = characters. URL-safe Base64 (RFC 4648 Section 5) replaces these with -, _ respectively and removes padding. If you cannot decode a Base64 string from an API, check the format first: if the string contains - or _ it is in URL-safe format and needs to be converted to +, /, and = before decoding. JWT tokens use URL-safe Base64, so if you need to decode a JWT payload separately, consider using our JWT Decoder tool.

Related Guides

In-depth articles covering the concepts behind Base64 Encoder / Decoder.

Related Tools