NC Logo UseToolSuite

Base64 Encoder / Decoder

Encode plain text to Base64 or decode Base64 strings back to text instantly. No data is sent to any server — all encoding and decoding happens locally in your browser.

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

What is Base64 Encoder / Decoder?

Base64 Encoder / Decoder is a free online tool that converts plain text into Base64-encoded strings and vice versa. Base64 is a binary-to-text encoding scheme that represents binary data using a set of 64 ASCII characters, making it safe for transmission over text-based protocols like HTTP, SMTP, and JSON. This tool handles the encoding and decoding process instantly in your browser, with full support for Unicode and UTF-8 characters. Your data never leaves your device, ensuring complete privacy.

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 like JWTs, or preparing data for email attachments in MIME format. It's also useful for debugging encoded data you encounter in logs, URLs, or configuration files.

Common use cases

Developers frequently use Base64 encoding to embed small images as data URIs in HTML and CSS, encode API credentials for HTTP Basic Authentication headers, encode and decode JWT token payloads for inspection, prepare file uploads for APIs that accept Base64-encoded content, and convert binary certificate data into a text-safe format. The URL-safe variant is used in JWTs and URL parameters where standard Base64 characters (+, /, =) would cause issues.

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.

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 Tools