Base64 Encode & Decode
runs in your browserEncode text or any file to Base64 and decode it back, with URL-safe output, line wrapping and data URIs. Unicode is handled correctly.
Text
Base64
about this tool
What Base64 is for
Base64 rewrites arbitrary bytes using 64 printable characters, so binary data can travel through something that only accepts text: a JSON field, an email header, a URL, a cookie, an HTML attribute. It is an encoding, not encryption. Anyone can decode it, and it makes data about a third larger.
Encoding text
Type or paste on the left, read the result on the right, and swap direction to
go back. Unicode is handled properly, which is worth spelling out because the
browser's own btoa is not: it only accepts Latin-1 and throws on anything
outside it, which is why so many pages fail on an emoji or a Greek name. Text is
encoded as UTF-8 first, and decoding runs a strict UTF-8 decode, so invalid
sequences are reported rather than quietly turned into replacement characters.
URL-safe output
Standard Base64 uses + and /, both of which mean something else in a URL or
a filename. URL-safe swaps them for - and _, the variant used by JWTs
and most token formats. Decoding accepts either alphabet without being told
which one you pasted.
Base64 is also what you will find inside a JWT. For the percent-encoding that URLs themselves use, see URL encode & decode.
Files and data URIs
Drop in a file and you get its Base64, optionally as a data URI —
data:image/png;base64,… — which is the form you paste into CSS or an img
tag to inline a small asset. The file is read in the page; it is not uploaded.
Line wrapping
MIME requires Base64 to be split every 76 characters, and some older parsers insist on it. Wrap does that. Leave it off for a token or a data URI, where a newline would break the value.
The gotcha with padding
Base64 pads its output with = so the length is a multiple of four. Many token
formats strip that padding. Decoding here restores it for you, so a JWT segment
copied out of a header decodes without you having to count characters.
questions
- Is Base64 a form of encryption?
- No. Base64 is an encoding: it rewrites bytes as printable characters and anyone can reverse it with no key. Use it to move binary data through text-only channels, never to protect it.
- Why does my emoji or accented text break in other Base64 tools?
- Because the browser's built-in btoa function only accepts Latin-1 and throws on anything outside it. This tool encodes text as UTF-8 first, so emoji, Greek, Chinese and accented characters all round-trip correctly.
- What is URL-safe Base64?
- A variant that replaces the + and / characters with - and _, because the standard ones have meaning inside URLs and filenames. JWTs and most token formats use it. Decoding here accepts either alphabet automatically.
- Why does my Base64 string end in one or two equals signs?
- That is padding, added so the length is a multiple of four. Many token formats strip it; this tool restores it when decoding, so a JWT segment pasted from a header works without you counting characters.
- Does Base64 make my data bigger?
- Yes, by roughly a third, because every three bytes become four characters. That is worth remembering before inlining a large image as a data URI.