Skip to content
English

Switch theme

// Tools · encoding

Base64 encode / decode

Convert text or files to Base64 and back. Chinese and emoji are handled as UTF-8, URL-safe strings and missing “=” are fine, and binary results get a hex preview, download and image preview.

Runs on your device – nothing is uploadedRFC 4648UTF-8URL-safe · data URI

Tip: you can drag a file anywhere onto this box to encode it.

Type or paste above; the result updates as you type.

01How to use

  1. Pick a direction: “Encode” turns text or a file into Base64; “Decode” turns Base64 back.
  2. Type or paste into the left box; the result appears on the right at once. Spaces and line breaks in Base64 are ignored, URL-safe strings and missing “=” are accepted.
  3. For a file, drag it onto the left box or click “Choose file”. Tick “Output data:URI” to get a string you can use directly in HTML or CSS.
  4. “⇄ Swap” puts the result into the input and flips the direction – handy for checking a round trip.

Related: URL encode / decode · all tools →

FAQ

Is my data uploaded?

No. Encoding and decoding happen in JavaScript on this page. The page sends no request containing your input, does not put it in the address bar, cookies or localStorage, and keeps it out of analytics. Files you drop in are read locally with the File API. You can check this in your browser’s developer tools (Network tab).

Why does decoding give garbled Chinese elsewhere?

Base64 encodes bytes, not characters. Chinese and emoji must first be turned into bytes with an encoding – almost always UTF-8. The browser’s btoa/atob work on Latin-1 only, which is the usual cause of garbled text or “InvalidCharacterError”. This tool always uses UTF-8 in both directions. If the bytes are not valid UTF-8 (for example GBK text or an image), it says so and shows the bytes instead of printing garbage.

What is URL-safe Base64?

RFC 4648 section 5 defines a variant that uses “-” and “_” instead of “+” and “/”, so the result can go into URLs and file names unchanged. JWTs use it, usually without “=” padding. When decoding, this tool accepts both alphabets automatically (but not mixed in one string); when encoding, tick “URL-safe” and optionally “No padding”.

The string is missing “=” at the end. Can it still be decoded?

Yes. Padding only fills the last group to 4 characters, so it can be restored from the length; the tool adds it automatically and tells you. Only a length where the last group has a single character (length mod 4 = 1) is impossible, because that cannot come from any byte sequence – usually a character was lost when copying.

Can I convert images or files?

Yes. Drag a file onto the page (or choose one) to get its Base64, optionally as a data:URI ready for HTML/CSS. Paste a data:image/…;base64,… string or raw Base64 of a PNG, JPEG, GIF or WebP to see the image; other binary data gets a hex preview and a download button. Files up to 10 MB.

Is Base64 encryption?

No. Base64 only changes how bytes are written so they survive text-only channels; anyone can decode it. Do not use it to hide passwords or keys.