How to use Base64 / URL
- 1. Pick a mode. Base64 for wire encodings, URL-safe Base64 for JWTs, or URI encode for query strings.
- 2. Encode or decode. Paste text on one side. The other side updates immediately. Use URL-safe when `+` and `/` would break a path.
- 3. Drop a file. Images and documents become `data:` URIs you can embed in CSS or HTML prototypes. Large files stay in local memory.
- 4. Copy the result. Copy text or the data URI. Nothing is uploaded; refresh the page to drop the bytes from memory.
About this tool
Base64 is a way to carry binary bytes through channels that prefer ASCII: JSON strings, XML, email (MIME), and data URIs. It is defined in RFC 4648. Every 3 bytes become 4 characters from `A–Z a–z 0–9 + /`, with `=` padding. Base64URL swaps `+` and `/` for `-` and `_` and often omits padding, which is what JWTs use. URL encoding (percent-encoding) is a different standard (RFC 3986) for putting reserved characters into URIs. This tool does both, locally.
When to use Base64
Use it when you must embed binary in JSON (small images, protobuf as a string, SHA hashes in config). Do not use it as encryption: it is an encoding. Anyone can decode it. Size expands by about 33%, which matters in cookies and query strings. For files in HTTP APIs, `multipart/form-data` or raw binary with a correct `Content-Type` is usually better than a giant Base64 field.
URL-safe variant and padding
Standard Base64 can include `+`, `/`, and `=`. Those characters have meaning in URLs and filenames. Base64URL replaces them and may drop padding because the length can be inferred. JWT header and payload segments are Base64URL without padding. If a decode fails, add padding until the length is a multiple of 4, then decode. PureDevKit does this automatically in decode mode.
Percent-encoding
`encodeURI` leaves characters that are valid in a URI as a whole; `encodeURIComponent` encodes everything that is not an unreserved character, which is what you want for query parameter values. Spaces become `%20` (or `+` in `application/x-www-form-urlencoded`). Hash fragments and already-encoded strings are a common double-encoding trap: decode once and inspect before encoding again.
Data URIs
A data URI looks like `data:image/png;base64,...`. Browsers can render it without another network request, which is handy for tests and email prototypes. They bloat HTML and are a poor substitute for a CDN in production. This tool builds the URI entirely with `FileReader.readAsDataURL` in your browser.
Code examples
Node
Buffer.from("hello").toString("base64");
Buffer.from(b64, "base64").toString("utf8");Browser
btoa(unescape(encodeURIComponent(text)));
decodeURIComponent(escape(atob(b64)));URL
encodeURIComponent("a=b&c");
decodeURIComponent(location.search.slice(1));