Free Tool · No signup required

Base64 Encoder & Decoder — Text or File, URL-Safe Mode, Zero Uploads

Encode text or any file to Base64 data URI — decode it back instantly

1
2
3

Base64 encoding is everywhere in web development: embedding images in CSS, sending binary data in JSON payloads, encoding JWT tokens, and storing file attachments in APIs. This tool handles all of these use cases without uploading anything. Type or paste text to encode or decode it instantly, with full UTF-8 support for Unicode characters. Drag and drop any file — an image, PDF, font, or binary — to get its complete Base64 data URI (data:image/png;base64,...) ready to embed directly in HTML or CSS. Toggle URL-safe mode to replace the + and / characters with - and _ for use in query strings and JWT headers.

How to Encode or Decode Base64

Type text or drop a file — encode or decode in one click with URL-safe support.

1
Step 1

Encode or decode text

Select the Encode or Decode tab. In Encode mode, type or paste your text and click Encode — the Base64 output appears in the right panel. In Decode mode, paste a Base64 string and click Decode to get the original text back. The tool handles Unicode characters correctly using UTF-8 encoding before applying Base64.

2
Step 2

Encode a file to a data URI

Drag and drop any file onto the drop zone, or click it to open a file picker. The file is read locally by your browser and converted to a Base64 data URI in the format data:type/subtype;base64,... — for example, data:image/png;base64,iVBOR... for a PNG image. You can embed this data URI directly in an HTML img src attribute or a CSS background-image property.

3
Step 3

Toggle URL-safe mode

Enable URL-safe mode to replace + with - and / with _ in the output. URL-safe Base64 is required for JWT tokens, URL query parameters, and any context where + and / have special meaning. The padding = characters are typically omitted in URL-safe contexts — toggle the Strip padding option if your target system requires it.

Features

Encode and decode Base64 text with full UTF-8 / Unicode support

Drag-and-drop file to Base64 data URI conversion

URL-safe Base64 mode (replaces +/ with -_)

Padding strip option for JWT and URL contexts

Zero uploads — all processing happens in your browser

Copy output to clipboard in one click

Works with any file type: image, PDF, font, binary, archive

Shows encoded size vs original size for reference

Related Tools

Frequently Asked Questions

What is Base64 encoding used for?

Base64 converts binary data into a string of printable ASCII characters so it can be safely transmitted through systems that only support text, such as JSON APIs, email (MIME), HTML attributes, and HTTP headers. Common uses include: embedding small images as data URIs in CSS, encoding JWT token segments, attaching files in API payloads, and sending binary data in XML or JSON.

Does Base64 compress my data?

No. Base64 encoding increases the size of data by approximately 33% because it encodes every 3 bytes of binary as 4 ASCII characters. It is an encoding scheme, not a compression algorithm. If you need to reduce size, compress first (gzip, deflate) and then encode the compressed binary to Base64.

What is URL-safe Base64?

Standard Base64 uses the characters + and / which have special meaning in URLs (+ is a space, / is a path separator). URL-safe Base64 replaces + with - and / with _ so the encoded string can appear in a URL query parameter or path segment without being URL-encoded. JWT tokens use URL-safe Base64 without padding.

Why do I get garbage characters when decoding?

If the decoded output contains garbled characters, the original encoding was likely not UTF-8. Some Base64 strings encode Latin-1 (ISO-8859-1) or other single-byte encodings. Also check that the input Base64 string is complete — a missing or extra character at the end will corrupt the entire decoded output.

Can I use a Base64 data URI instead of a real image URL?

Yes, for small images (under ~10 KB). A data URI embeds the image directly in the HTML or CSS, eliminating one HTTP request. However, data URIs cannot be cached separately by the browser and they increase the size of the document. For images larger than 10 KB, serving them as separate files with proper caching is more efficient.