Skip to content

Base64 encode and decode text or files, free, in your browser

Base64 is a way of representing binary data using 64 printable characters (A–Z, a–z, 0–9, + and /) so it can travel through systems that only handle text, such as email, JSON and data URLs. Every 3 bytes become 4 characters, so encoded data is about 33% larger. To decode, map each character back to 6 bits and reassemble the bytes. This tool encodes and decodes text and files locally, supports the URL-safe alphabet, and can produce data: URLs for images.

C3Base64 encode / decode — ToolsBoxx
Ready0 B sent to server

Your files never leave your device. Processing happens in your browser.How that works.

How it works

  1. Paste text or Base64, or drop a file.
  2. Choose Encode or Decode; the direction is guessed from the input.
  3. Copy the result or download decoded data as a file.

Runs as JavaScript inside this tab. Turn off your connection after the page loads and it still works.

Base64 reference

How it works

Base64 (RFC 4648) takes binary data three bytes (24 bits) at a time and splits them into four 6-bit groups. Each group (0–63) is written as one character from a 64-character alphabet. When the input length is not a multiple of three, the last block is padded and = signs mark how many bytes were missing.

Input bytes Output chars Padding
3n 4n none
3n + 1 4n + 4 ==
3n + 2 4n + 4 =

Encoded size ≈ input × 4/3, plus line breaks if wrapped.

Alphabets

Variant Characters 62 and 63 Padding Used by
Standard (base64) + / = Email (MIME), data URLs, HTTP Basic auth, most APIs
URL-safe (base64url) - _ usually omitted JWT, URL parameters, file names, OAuth

Both share A–Z a–z 0–9 for values 0–61. The decoder on this page accepts either variant and ignores whitespace and missing padding.

Alphabet table

Value Char Value Char Value Char Value Char
0 A 16 Q 32 g 48 w
1 B 17 R 33 h 49 x
2 C 18 S 34 i 50 y
3 D 19 T 35 j 51 z
4 E 20 U 36 k 52 0
5 F 21 V 37 l 53 1
6 G 22 W 38 m 54 2
7 H 23 X 39 n 55 3
8 I 24 Y 40 o 56 4
9 J 25 Z 41 p 57 5
10 K 26 a 42 q 58 6
11 L 27 b 43 r 59 7
12 M 28 c 44 s 60 8
13 N 29 d 45 t 61 9
14 O 30 e 46 u 62 + (or -)
15 P 31 f 47 v 63 / (or _)

Data URLs

data:image/png;base64,iVBORw0KGgo… embeds a file directly in HTML or CSS. Useful for small icons (under a few KB); wasteful for larger files because Base64 is 33% bigger and cannot be cached separately.

In code

Language Encode Decode
JavaScript (text) btoa(unescape(encodeURIComponent(s))) or Buffer.from(s).toString('base64') Buffer.from(b64, 'base64').toString()
Python base64.b64encode(data) base64.b64decode(s)
Shell base64 file base64 -d file
PowerShell [Convert]::ToBase64String($bytes) [Convert]::FromBase64String($s)

Note btoa only handles Latin-1; encode to UTF-8 bytes first for other text.

Worked examples

“Hi” → SGk=

Two bytes (72, 105) = 16 bits → three 6-bit groups (18, 6, 36) plus one = for the missing byte: S G k =.

“Man” → TWFu

Three bytes exactly: no padding.

“Hello, ToolsBoxx! 🧰” → SGVsbG8sIFRvb2xzQm94eCEg8J+nsA==

The emoji is four UTF-8 bytes (F0 9F A7 B0), which is why the output ends with 8J+nsA==.

URL-safe encoding of the same text: SGVsbG8sIFRvb2xzQm94eCEg8J-nsA — + becomes - and padding is dropped, safe for a query string.

Decoding an image

Paste data:image/png;base64,iVBORw0KGgoAAAANSUhEUg… and the tool recognises the PNG signature, shows a preview and offers a download. The same works for PDF, ZIP, JPEG, GIF, WEBP and MP3 by inspecting the first bytes.

Encoding a file for CSS

Click Encode a file…, choose an SVG icon, then Copy data: URL and paste into background-image: url("…").

Frequently asked questions

Is Base64 encryption?

No. Base64 is an encoding that anyone can reverse. It hides nothing; use it for transport, not for secrets.

What is URL-safe Base64?

A variant that replaces + with - and / with _ so the result can be used in URLs and filenames without escaping. JWTs use it. Toggle URL-safe to switch.

Why does my decoded text look garbled?

The Base64 probably encodes binary data, not text, or text in a different character set. Try the file download option, or check that the input has no line breaks or stray characters.

Why is the Base64 output longer than my input?

Because 6 bits of data are stored per character, every 3 bytes become 4 characters. Padding with = brings the length to a multiple of 4.

Can I convert an image to Base64 for CSS or HTML?

Yes. Drop the image and copy the data: URL, which includes the MIME type prefix that browsers need.

Base64 encode / decode · last updated · changelog · part of Canned Tuna