⚡Free Tools

Base64 Encode & Decode — Text, Images and Files

Encode or decode Base64 instantly with correct Unicode, URL-safe mode and clear error positions. Turn any image or file into a data URI, or paste Base64 to get the original file back — all inside your browser.

Input
Output

What Base64 is, in one minute

Base64 is a way to write any bytes — text, an image, a PDF, a font — using only 64 safe characters: A–Z, a–z, 0–9, + and /, with = as padding at the end. Every 3 bytes of input become 4 characters of output, so Base64 is always about 33% larger than the original (4 ÷ 3 = 1.333). It is not encryption and not compression. Anyone can decode it, so never treat Base64 as a way to hide a password or an API key.

It exists because many systems were built to carry text, not raw bytes. E-mail attachments, JSON APIs, HTML and CSS files, XML documents, environment variables, HTTP Basic authentication headers and JWT tokens all use Base64 to move binary data safely through channels that might otherwise corrupt it.

How to use this Base64 encoder and decoder

  1. Text tab. Choose Encode or Decode, then type or paste. The result updates as you type. Swap moves the output to the input and flips the direction, which is the fastest way to check a round trip.
  2. File / image → Base64. Drop any file. You get the Base64 plus ready-to-paste snippets: a full data URI, raw Base64, an HTML <img> tag, a CSS background-image rule, Markdown or a small JSON object. The panel shows the original size, the Base64 size and the exact overhead, and previews images with their pixel dimensions.
  3. Base64 → file / image. Paste a bare Base64 string, a data URI, a whole <img src="data:…"> tag or a CSS url(data:…). The tool finds the Base64 inside, decodes it, recognises the real file type from its first bytes (the “magic number”) and lets you download it with the correct extension.

Everything runs inside your browser tab. Files are read with the browser's FileReader and never sent to any server. That matters, because Base64 is often used for exactly the things you should not upload: API credentials, signed documents, certificates and private images. Once the page has loaded it also works offline, and you can install it as an app from the header.

What makes this tool different

Base64 vs base64url vs data URI

FormAlphabet / shapeWhere you see it
Standard Base64A–Z a–z 0–9 + /, padded with =E-mail attachments, JSON payloads, PEM files, HTTP Basic auth
base64urlA–Z a–z 0–9 - _, padding often droppedJWT header and payload, OAuth PKCE, URLs and file names
Data URIdata:<mime>;base64,<payload>Inline images in HTML, CSS and e-mail templates

When to inline an image as Base64 — and when not to

Inlining a small icon, logo or placeholder as a data URI removes one HTTP request and keeps a single HTML file self-contained, which is handy for e-mail signatures, offline reports and tiny widgets. For anything bigger than a few kilobytes it is usually a bad trade: the file grows by a third, the browser cannot cache it separately from the page, and large strings slow down HTML and CSS parsing. Some e-mail clients also block data URIs. As a rule of thumb, inline images under about 4 KB and serve everything else as a normal file. If an image is too large, shrink it first with our image compressor, then encode it here.

Common real-world tasks

Why does the same text give a different Base64 elsewhere?

Base64 encodes bytes, not letters, so the result depends on how the text was turned into bytes. “é” is one byte in Latin-1 but two bytes in UTF-8, so the outputs differ. A trailing newline added by echo on the command line also changes the output: echo "hi" | base64 gives aGkK, while the text “hi” alone gives aGk=. Windows line endings (CRLF) and invisible characters such as a byte-order mark cause the same effect. If two tools disagree, check the character set and the line endings first.

Size limits and performance

Text mode comfortably handles several megabytes. The File tab can encode files of tens of megabytes; very long outputs are shown in part, while Copy and Download always give the full result. Because work happens on your device, the practical limit depends on its memory. Phones handle smaller files than desktops.

Sources and standards

Frequently asked questions

Is Base64 encryption?

No. Base64 is a reversible encoding that anyone can decode in one step. Use it to transport data safely through text-only channels, never to protect secrets.

Why does btoa() fail on my text?

The browser's btoa() only accepts characters up to U+00FF. Hindi, emoji and most non-Latin text must be converted to UTF-8 bytes first. This tool does that automatically.

What is URL-safe Base64 (base64url)?

It is the RFC 4648 section 5 variant that uses - and _ instead of + and /, so the result can sit in URLs and file names. JWTs use it without = padding. Tick URL-safe to encode; decoding detects it automatically.

How much bigger does Base64 make a file?

About 33%: every 3 bytes become 4 characters. With 76-character MIME line breaks it is about 37%. The File tab shows the exact overhead for your file.

How do I convert a Base64 string back to an image or PDF?

Open the “Base64 → file / image” tab and paste the string or data URI. The tool detects the real type from the file's first bytes, previews images and downloads the file with the right extension.

Are my files uploaded anywhere?

No. Encoding and decoding run entirely in your browser. Nothing is sent to a server, and the page works offline after it loads.

Why is my Base64 different from another tool's?

Usually the text was converted to bytes differently (UTF-8 vs Latin-1 vs UTF-16), or one side included a trailing newline or Windows line endings. Match the character set and line endings and the output will match.

Keyboard shortcuts

Ctrl + EnterConvert now
Ctrl + Shift + SSwap input and output