• Free forever
  • No sign-up
  • Private — runs in your browser

Base64 & URL Encoder / Decoder

Encode or decode Base64 and URL-encoded text as you type, or turn files and images into Base64 data URIs and back. Everything stays in your browser.

Base64

How to use it

  • Base64: choose Encode and type or paste text — the Base64 appears as you type. Choose Decode to turn Base64 back into text. Tick URL-safe for Base64URL (JWTs, URLs, file names) or Wrap at 76 for email (MIME).
  • URL encoding: percent-encode text for use in a URL, or decode a URL full of %20s back into readable text.
  • File ↔ Base64: drop any file to get its Base64 or a ready-to-paste data URI — or paste Base64 to download it as a file again.
  • ⇄ Swap moves the result into the input and flips the direction, handy for checking a round trip.

How Base64 works

Base64 takes the input three bytes (24 bits) at a time and splits them into four groups of 6 bits. Each 6-bit value (0–63) maps to one character of the alphabet A–Z a–z 0–9 + /. When the input isn't a multiple of three bytes, the output is padded with =.

TextBytes (hex)Base64
Man4D 61 6ETWFu
Ma4D 61TWE=
M4DTQ==
café63 61 66 C3 A9Y2Fmw6k=

Note how é takes two bytes in UTF-8 — that's why encoding text correctly means converting it to UTF-8 first.

Common uses of Base64

  • Data URIs — embedding small images, icons or fonts directly in HTML or CSS: data:image/png;base64,iVBORw0…
  • Email attachments — MIME encodes attachments as Base64 wrapped at 76 characters.
  • APIs and JSON — sending binary data such as images or PDFs inside JSON, which only supports text.
  • JSON Web Tokens — a JWT's header and payload are Base64URL-encoded JSON (paste one part into the decoder to read it).
  • HTTP Basic authentication — the Authorization header carries username:password in Base64. Since Base64 isn't encryption, it must only be used over HTTPS.

URL encoding (percent-encoding)

URLs may only contain a limited set of ASCII characters, and some characters — / ? # & = — have special meanings. Percent-encoding replaces anything else with % followed by the byte's two-digit hex code, after converting the text to UTF-8.

CharacterEncodedCharacterEncoded
space%20 (or + in forms)&%26
/%2F=%3D
?%3F#%23
@%40é%C3%A9

Encode each query-string value separately, not the whole URL — otherwise the ? and & that structure the URL get escaped too. If you do need to clean up a whole URL, choose Keep URL structure.

LanguageEncodeDecode
JavaScript (browser)btoa(String.fromCharCode(...new TextEncoder().encode(s)))new TextDecoder().decode(Uint8Array.from(atob(b), c => c.charCodeAt(0)))
Node.jsBuffer.from(s).toString('base64')Buffer.from(b, 'base64').toString()
Pythonbase64.b64encode(s.encode()).decode()base64.b64decode(b).decode()
PHPbase64_encode($s)base64_decode($b)
Command lineecho -n 'text' | base64echo 'dGV4dA==' | base64 --decode

Frequently asked questions

What is Base64?

Base64 is a way of writing any binary data using only 64 safe text characters (A–Z, a–z, 0–9, + and /). It lets images, files and other bytes travel through systems that only handle text — email, JSON, HTML, URLs and HTTP headers. It is encoding, not encryption: anyone can decode it.

Why is Base64 bigger than the original?

Every 3 bytes of input become 4 characters of output, so Base64 is about 33% larger (plus a little more if lines are wrapped). That's why inlining large images as data URIs makes pages heavier.

Does it handle emoji and non-English text?

Yes. Text is converted to UTF-8 bytes before encoding, so “café”, “日本語” and emoji encode and decode correctly. Many simple tools use the browser's btoa() directly, which fails on any character outside Latin-1.

What is Base64URL?

A variant that replaces + with - and / with _ and usually drops the trailing = padding, so the result is safe inside URLs and file names. It's used in JSON Web Tokens (JWTs) and many web APIs. The decoder accepts both variants automatically.

What's the difference between encodeURIComponent and encodeURI?

encodeURIComponent (“Encode everything”) escapes every character with special meaning in a URL, including / ? & = and #. Use it for a single value, such as a query parameter. encodeURI (“Keep URL structure”) leaves those characters alone so a full URL keeps working, escaping only spaces and characters that aren't allowed at all.

Why do spaces become + in some URLs and %20 in others?

HTML forms submit data as application/x-www-form-urlencoded, where a space is written as +. Everywhere else in a URL, a space is %20. Choose “Form style” when you're working with form data or query strings created by a form.

Is my data uploaded?

No. All encoding and decoding happens in your browser with JavaScript, including files — nothing is sent to a server.