Base64 Encode / Decode

Encode text or a file to base64, or decode a base64 string (or data: URL) back. Everything runs in your browser — nothing is uploaded.

0 chars0 lines0 bytes

…or drop a file to encode

Drag a file here, or

0 chars0 lines0 bytes

What is Base64 Encode / Decode?

Base64 Encode / Decode is a browser-based tool that converts text and files into base64 — a way of representing arbitrary binary data using only 64 safe, printable ASCII characters — and converts base64 strings back to their original form. Drop a file to get a ready-to-use data: URL, or paste base64 (or a data URL) to decode it back to text.

Base64 exists to move binary data through channels that were designed for text. Email, JSON payloads, URLs, HTML attributes, and many configuration formats cannot safely carry raw bytes, because certain byte values have special meaning or are not printable. Base64 re-encodes those bytes into a compact alphabet of letters, digits, plus, and slash, so the data survives copy-paste and text transport intact and can be decoded back exactly.

Every conversion runs locally in your browser. Files you drop are read in memory and encoded on the spot — nothing is uploaded, so even sensitive files and secrets stay on your machine.

Why use Base64 Encode / Decode?

Base64 is everywhere in web development: embedding small images as data URLs in CSS or HTML, encoding binary attachments in emails, packing credentials into HTTP Basic Auth headers, and storing binary blobs inside JSON. Being able to encode and decode it instantly saves you from writing throwaway scripts every time you need to inspect or produce a base64 value.

The file-to-data-URL feature is especially handy. Drop an icon, font, or small image and get a self-contained data: URL you can paste directly into a stylesheet or markup, eliminating an extra HTTP request. Decode mode lets you peek inside a base64 blob you found in a log, a token, or a config file to see what it really contains.

Doing this locally matters for privacy. Files and strings you encode may contain credentials, private keys, or confidential documents. This tool never sends anything to a server — you can confirm zero network requests in your browser's Network tab while encoding a file.

Features

  • Encode text to a base64 string
  • Decode base64 (or a data: URL) back to text
  • Drag and drop a file to encode it as a base64 data URL
  • Reports file name, size, and detected MIME type
  • Clear, specific errors when a base64 string is malformed
  • One-click copy of the result to your clipboard
  • Download the result to a file
  • Runs entirely in your browser — no uploads, works offline

How to use Base64 Encode / Decode

  1. Choose Encode to turn text or a file into base64, or Decode to convert base64 back to text.
  2. In Encode mode, type or paste text into the input, or drag and drop a file to produce a base64 data: URL.
  3. In Decode mode, paste a base64 string or a full data: URL into the input.
  4. The result appears in the right panel automatically.
  5. Copy the result to your clipboard or download it as a file.

Example 1 — Encode text to base64

Paste text in Encode mode to get its base64 representation, ready to drop into a header, JSON field, or URL.

Input

hello world

Output

aGVsbG8gd29ybGQ=

Example 2 — Decode a base64 string

Switch to Decode mode and paste base64 (or a data URL) to recover the original text.

Input

VG9vbEJlbmNoIHJvY2tz

Output

ToolBench rocks

Common Mistakes

  • Confusing base64 with encryption: base64 is an encoding, not a cipher. Anyone can decode it instantly. Never use it to hide passwords, tokens, or secrets — it provides no security whatsoever.
  • Forgetting URL-safe variants: standard base64 uses + and / characters, which have special meaning in URLs. If a value must go in a URL or filename, it needs the URL-safe variant (- and _) or percent-encoding, or it may break.
  • Dropping the padding: the trailing = characters pad the string to a multiple of four. Removing them (or adding extra) causes decode errors in strict parsers. Copy the full string including any = padding.
  • Assuming base64 shrinks data: it does the opposite. Base64 inflates binary by roughly 33%, so an encoded file is always larger than the original. It is about transport safety, not compression.
  • Whitespace and line breaks in the input: some sources wrap base64 across lines. Stray newlines or spaces pasted into decode mode can cause failures in strict decoders — clean them up first.
  • Mis-decoding a data URL as raw base64: a data: URL has a prefix (data:...;base64,) before the actual base64. Decode the base64 portion, not the whole prefix, unless the tool handles the prefix for you.

Developer Tips

  • Use data URLs for tiny, frequently-used images or icons to eliminate an HTTP request — but avoid them for large assets, since the ~33% size inflation and lost caching usually outweigh the saved request.
  • When you encounter a mysterious base64 blob in a log or config, decode it here first to see whether it is JSON, an image, a token payload, or something else before writing any code around it.
  • Remember that HTTP Basic Auth credentials are just base64-encoded username:password — decoding one reveals the plaintext, which is exactly why Basic Auth must only be used over HTTPS.
  • For values that travel in URLs or filenames, switch to a URL-safe base64 variant or percent-encode the result so the + and / characters do not cause problems.
  • Base64 is not a substitute for hashing or encryption — if you need integrity or confidentiality, use the Hash Generator or a real encryption step, not base64 encoding.

Frequently Asked Questions

Is base64 a form of encryption?
No, and this is a critical distinction. Base64 is a reversible encoding that anyone can decode without any key — it simply represents bytes using a text-safe alphabet. It provides zero security. If you base64-encode a password or token, anyone who sees the string can recover the original in seconds. To actually protect data, use encryption; to verify integrity, use a cryptographic hash.
Why is my base64 output larger than the input?
Base64 represents every three bytes of input using four output characters, so the encoded result is about 33% larger than the original data, plus a little padding. That growth is inherent to the encoding — it trades size for the ability to travel safely through text-only channels. Base64 is never a compression tool; if you need smaller data, compress it first (for example with the Compress / Decompress tool) and then base64 the compressed bytes.
What is a data URL and when should I use one?
A data URL embeds a file directly inside a URL using the form data:[mime-type];base64,[data]. It lets you inline an image, font, or other small asset into HTML or CSS without a separate file or HTTP request. This tool generates one automatically when you drop a file. Data URLs are best for very small, frequently-used assets; for larger files the size inflation and loss of caching make a normal file reference the better choice.
Are my files uploaded when I encode them?
No. When you drop a file, it is read into memory and encoded entirely within your browser using JavaScript — nothing is sent to a server, logged, or stored. This means you can safely encode sensitive files like keys, certificates, or private documents. You can verify it by opening your browser's Network tab while encoding a file: there are zero outbound requests, and the tool works even offline.
What is the difference between standard and URL-safe base64?
Standard base64 uses the characters + and / (and = for padding). Those characters have special meaning in URLs and some filenames, so a URL-safe variant replaces + with - and / with _, and often omits the padding. If you paste standard base64 into a URL without encoding it, the + and / can be misinterpreted. Choose the variant that matches where the string will be used, or percent-encode a standard string before putting it in a URL.
Why does decoding fail with an error?
Common causes are incorrect or missing padding (the trailing = characters), whitespace or line breaks embedded in the string, characters that are not part of the base64 alphabet, or trying to decode a URL-safe string with a standard decoder (or vice versa). The tool reports a clear error when the input is not valid base64. Copy the full, unbroken string exactly as it appears at the source and remove any stray whitespace before decoding.
Can I decode base64 back into a binary file?
This tool decodes base64 to text, which is ideal when the encoded content was text (like JSON or a token payload) or a data URL you want to inspect. If the original was a true binary file such as an image, the decoded bytes are not meaningful as text — you would need to save them as a file with the correct extension. For inspecting binary blobs, decoding to see the header or MIME type is often enough to identify what the data is.