Base64 & URL Encoder / Decoder
Convert strings between raw text, Base64, and URL-encoded formats client-side. Safe for sensitive tokens.
window.btoa / atob / encodeURIComponent.No data sent over wireBase64 examples: how text becomes Base64
Base64 uses 64 safe characters (A to Z, a to z, 0 to 9, + and /) to write out any data. Every 3 bytes of input become 4 characters of output, and = signs pad the end. Here are real results from the encoder.
TWFuWhy: 3 bytes become exactly 4 characters, so no padding
TWE=Why: 2 bytes leave a gap, filled with one =
TQ==Why: 1 byte leaves a bigger gap, filled with two =
SGVsbG8sIFdvcmxkIQ==Why: 13 characters become 20
Y2Fmw6k=Why: รฉ takes two bytes in UTF-8, so 5 bytes become 8 characters
8J+YgA==Why: One emoji is four bytes
| Text | Base64 | Why |
|---|---|---|
Man | TWFu | 3 bytes become exactly 4 characters, so no padding |
Ma | TWE= | 2 bytes leave a gap, filled with one = |
M | TQ== | 1 byte leaves a bigger gap, filled with two = |
Hello, World! | SGVsbG8sIFdvcmxkIQ== | 13 characters become 20 |
cafรฉ | Y2Fmw6k= | รฉ takes two bytes in UTF-8, so 5 bytes become 8 characters |
๐ | 8J+YgA== | One emoji is four bytes |
URL-safe variant. Standard Base64 uses + and /, which have special meanings in web addresses. The URL-safe form swaps them for - and _ and drops the padding. For the text >>>??? the standard output is Pj4+Pz8/ and the URL-safe output is Pj4-Pz8_. Tick the URL-safe box when encoding, and decoding recognises either form.
Decoding examples, including messy input
Pasted Base64 is often not perfectly clean. The decoder copes with the common problems and tells you what it changed.
{"alg":"HS256","typ":"JWT"}What happened: The header of a JSON Web Token (the part before the first dot)
HelloWhat happened: The missing = padding is added, and the tool says so
HelloWhat happened: The data: prefix is removed, and the tool says so
>>>???What happened: URL-safe Base64 (- and _) is recognised automatically
ff d8 ff e0 00 10What happened: These bytes are not text (they begin a JPEG image), so they are shown as hex
Error: '!' is not a Base64 character (character 10)What happened: Errors name the character and its position
| Input | Result | What happened |
|---|---|---|
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9 | {"alg":"HS256","typ":"JWT"} | The header of a JSON Web Token (the part before the first dot) |
SGVsbG8 | Hello | The missing = padding is added, and the tool says so |
data:text/plain;base64,SGVsbG8= | Hello | The data: prefix is removed, and the tool says so |
Pj4-Pz8_ | >>>??? | URL-safe Base64 (- and _) is recognised automatically |
/9j/4AAQ | ff d8 ff e0 00 10 | These bytes are not text (they begin a JPEG image), so they are shown as hex |
not base64!! | Error: '!' is not a Base64 character (character 10) | Errors name the character and its position |
Decoding a JSON Web Token shows you what it carries, but it does not check that the token is genuine, because that needs the secret key. A token's contents are only encoded, not hidden, so treat tokens as private and do not paste a live one into any site you do not trust. Here, nothing leaves your browser.
URL (percent) encoding: what changes and why
Web addresses can only contain a limited set of characters. Anything else is written as a percent sign followed by the character's byte value in hex. The URL tab leaves letters, digits and - _ . ! ~ * ' ( ) alone and escapes the rest:
%20Why it matters: Not + (see the notes below)
%26Why it matters: Otherwise it would start a new parameter
%3DWhy it matters: Otherwise it would split a name from a value
%3FWhy it matters: Otherwise it would start the query string
%2FWhy it matters: Otherwise it would add a path segment
%40Why it matters: As in an email address
%2BWhy it matters: Otherwise a form decoder may read it as a space
%25Why it matters: The escape character itself
%C3%A9Why it matters: Letters outside A to Z use their UTF-8 bytes
%E2%82%ACWhy it matters: Three bytes
%F0%9F%98%80Why it matters: Four bytes
| Character | Becomes | Why it matters |
|---|---|---|
| Space | %20 | Not + (see the notes below) |
| & | %26 | Otherwise it would start a new parameter |
| = | %3D | Otherwise it would split a name from a value |
| ? | %3F | Otherwise it would start the query string |
| / | %2F | Otherwise it would add a path segment |
| @ | %40 | As in an email address |
| + | %2B | Otherwise a form decoder may read it as a space |
| % | %25 | The escape character itself |
| รฉ | %C3%A9 | Letters outside A to Z use their UTF-8 bytes |
| โฌ | %E2%82%AC | Three bytes |
| ๐ | %F0%9F%98%80 | Four bytes |
- Encode a value, not the whole link.
hello world & morebecomeshello%20world%20%26%20more, which is what you want inside a query string. Encoding a complete address turnshttps://intohttps%3A%2F%2F, which is only right when that address is itself a parameter. - A plus sign stays a plus sign. Decoding
a+bgivesa+b. In old-style form data a + meant a space, so replace it first if you need that. - A lone % is an error.
50%cannot be decoded, because a % must be followed by two hex digits. Write a literal percent sign as%25.
Related: format and check a JSON payload with the JSON formatter, generate random identifiers with the UUID generator, or read a number in another base with the number base converter.
Frequently Asked Questions
What is Base64 encoding used for?โผ
Base64 turns bytes into plain text characters so they can travel safely through systems that only handle text, such as JSON, email, data URLs and HTTP headers. It is an encoding, not encryption: anyone can decode it.
What is URL-safe Base64?โผ
It swaps + and / for - and _ and usually drops the = padding, so the result is safe in web addresses and filenames. JSON Web Tokens use this form. Tick the URL-safe option when encoding; decoding accepts both forms automatically.
Why does my decoded Base64 show hex numbers instead of text?โผ
If the decoded bytes are not valid UTF-8 text, such as an image or a compressed file, they are shown as hex instead of as unreadable symbols.
Does it cope with a data: prefix, line breaks or missing padding?โผ
Yes. A leading data:...;base64, prefix, spaces and line breaks are ignored and missing = padding is added. A note tells you what was adjusted.
What is the difference between URL encoding and Base64?โผ
URL (percent) encoding escapes only the characters that are unsafe in a web address, for example a space becomes %20. Base64 re-writes the whole input in a different alphabet and makes it about a third larger.
Does it support emoji and non-English text?โผ
Yes. Text is converted as UTF-8, so accents, emoji and other scripts round-trip correctly.
Why does Base64 end with one or two = signs?โผ
Base64 turns every 3 bytes into 4 characters. If the input is not a multiple of 3 bytes, the end is padded with = so the length is a multiple of 4. One byte left over gives two = signs, and two bytes left over gives one. URL-safe Base64 often leaves the padding off, and this tool adds it back when decoding.
How much bigger does Base64 make my data?โผ
About a third bigger, because 3 bytes become 4 characters. For example 300 characters of plain English text become 400 Base64 characters. That is the price of making binary data safe to put in text-only places.
Should I encode a whole web address or just part of it?โผ
Usually just the part that varies, such as a search term or a value in the query string. This tool uses encodeURIComponent, which also encodes the characters that structure a URL, so the whole address https://example.com/a b becomes https%3A%2F%2Fexample.com%2Fa%20b. That is correct when the address is itself a value inside another URL, and wrong when you want a working link.
Why does a + stay a + when I decode a URL?โผ
Percent-decoding changes only %XX codes. In the older form-submission format a + stands for a space, but in a normal URL a + is just a plus sign, so the tool keeps it. If you are decoding form data and need the spaces, replace each + with a space first.
Is Base64 safe for passwords or secrets?โผ
No. It is a format, not protection. Anyone can decode it in a second, as this page shows. Web servers sometimes use it for a login header, for example user:pass becomes dXNlcjpwYXNz, which is why that header must only ever be sent over HTTPS.