Base64
Encode and decode Base64 strings
What is Base64 and when is it used?
Base64 represents arbitrary bytes using only 64 printable ASCII characters (A–Z, a–z, 0–9, `+`, `/`). It's used to embed binary data in places that expect text — email attachments (MIME), data URIs (`data:image/png;base64,...`), JWT tokens, basic-auth headers, and configuration files.
Encoding adds about 33% overhead — three input bytes become four output characters. The browser's native `btoa`/`atob` only handles Latin-1 strings, so this tool wraps them with proper UTF-8 conversion to avoid 'character out of range' errors when encoding emoji or non-Latin text.
Use cases
- Embed small assets inline — convert a 1×1 tracking pixel or SVG icon into a data: URI you can paste into CSS or HTML.
- Encode binary in plain-text channels — wrap protobuf, images, or signatures in Base64 so they ride safely through JSON, email, or query strings.
- Encode tokens or IDs — this outputs standard Base64; for URL or filename use, swap `+` to `-` and `/` to `_` yourself.
- Inspect JWTs and OAuth state — Base64-decode each segment of a JWT to read the header and payload without trusting an online debugger.
Examples
| Input | Result |
|---|---|
| Hello, World! | SGVsbG8sIFdvcmxkIQ== |
| Café ☕ | Q2Fmw6kg4piV |
Frequently asked questions
Why does the browser's native btoa fail on emoji?
`btoa` only accepts Latin-1 (single-byte) characters. Multi-byte UTF-8 sequences trigger 'InvalidCharacterError'. This tool encodes to UTF-8 bytes first, then to Base64 — handles any Unicode.
What's URL-safe Base64?
A variant that replaces `+` with `-` and `/` with `_` so the string is safe in URLs and filenames. Note: this tool outputs standard Base64, so make that swap yourself if you need the URL-safe form.
Why does the decoded output look garbled?
Either the Base64 was corrupted, was URL-safe (this tool decodes standard Base64 — swap `-` back to `+` and `_` to `/` first), or wasn't text to begin with — Base64 routinely encodes binary data that doesn't decode to readable text.
Is Base64 secure?
No — Base64 is encoding, not encryption. Anyone can decode it. Use it for transport, not for hiding secrets.
Does the tool log anything?
No. Encoding and decoding happen in your browser; nothing is sent to a server.
