Base64 Encoder and Decoder Online

Convert text to Base64 and back, turn any file into a data URI you can paste straight into CSS or an img tag, or decode a Base64 blob back into a real downloadable file. Text conversion is UTF-8 safe, so emoji, accented letters and Devanagari survive the round trip intact — which is where the browser's raw btoa function falls over. When you decode something, the tool reads its magic bytes to work out what it actually is, previews it if it is an image, and names the download with the right extension. There is also a URL-safe toggle for Base64 that has to travel inside a URL or a JWT.

Base64 Encoder and Decoder

Encoding and decoding both run in this tab.

Runs fully in your browser. Nothing is uploaded.

How to Use the Base64 Encoder / Decoder

  1. On the Text tab, type in the top box and press Encode; the Base64 appears below. Paste Base64 in the lower box and press Decode to go the other way.
  2. Tick URL-safe variant when the Base64 has to sit inside a URL, a filename or a JWT, so plus and slash do not need escaping.
  3. On File to Base64, drop a file in and choose how you want it: a full data URI, the raw Base64, or a ready CSS background rule.
  4. On Base64 to file, paste the string — with or without a data: prefix — and press Decode. Images preview immediately.
  5. Press Download file and you get a real file with the extension matching what the bytes actually are.

Features

  • UTF-8 safe text conversion, so emoji and non-Latin scripts survive the round trip.
  • File to data URI in one step, with a CSS background variant ready to paste into a stylesheet.
  • File type detection from magic bytes rather than from a claimed MIME type.
  • Automatic image preview and a correctly named download when decoding.
  • URL-safe Base64 with the padding stripped, for URLs, filenames and JWT segments.
  • Clear error reporting when a string is not valid Base64, instead of silent nonsense.

About This Tool

Base64 turns arbitrary bytes into 64 safe printable characters, which lets binary data travel through systems built for text: email attachments, JSON payloads, data URIs in CSS, and the segments of a JWT. The cost is size. Three bytes become four characters, so encoded data is about 33 per cent larger than the original, plus padding.

That overhead is why inlining files as data URIs is a trade-off rather than an optimisation. A small icon or a decorative SVG inlined into CSS saves an HTTP request and is usually worth it. A 400 KB photograph becomes 533 KB of text that cannot be cached separately, blocks the stylesheet it sits in, and has to be re-downloaded with every change to that file. The useful rule of thumb is a few kilobytes.

The usual trap with Base64 in the browser is that btoa only handles characters in the range 0 to 255, so any emoji or accented character throws an error. This tool encodes your text to UTF-8 bytes first and then converts those bytes, which is what every other language does and is why a round trip here returns exactly what you put in.

Two more things worth knowing. Base64 is encoding, not encryption — anyone can decode it, so it hides nothing and protects nothing. And the URL-safe variant exists because plus and slash have meanings inside a URL; it swaps them for hyphen and underscore and drops the equals padding, which is the form you will see in JWTs and in many APIs.

Frequently Asked Questions

Is Base64 a form of encryption?

No. It is a reversible encoding with no key and no secret. Anyone who sees a Base64 string can decode it in seconds. Never use it to hide a password, a token or anything else that matters.

Why does my emoji break in other Base64 tools?

Because they call the browser's btoa function directly, and it only accepts characters up to code point 255. This tool encodes your text as UTF-8 bytes first, so emoji, accented letters and non-Latin scripts all round trip correctly.

Should I inline images as data URIs?

Only small ones. Base64 adds about a third to the file size and the result cannot be cached separately from the file it sits in. Inlining a small icon or SVG saves a request and is usually worth it; inlining a photograph is not.

What is URL-safe Base64?

A variant that replaces + with - and / with _, and drops the = padding, so the string can appear in a URL, a filename or a JWT without escaping. Tick the box on the text tab to produce or read it.

How does the decoder know the file type?

It reads the first few bytes — the magic number — and matches them against known signatures for PNG, JPEG, GIF, WebP, PDF, ZIP and others. That is more reliable than trusting a MIME type stated in the data URI, which anyone can write incorrectly.

Related Tools

Hash Generator

Hash text or files with MD5 and SHA, then compare against a checksum.

Open Hash Generator

JSON Formatter

Beautify, minify and validate JSON with exact error line and column.

Open JSON Formatter

Case Converter

Switch text between upper, title, camel, snake and kebab case instantly.

Open Case Converter

Favicon Generator

Generate every favicon size from one image and copy the HTML tags.

Open Favicon Generator

Browse all 20 tools →