About This Tool
NinjaFunction's URL Encoder / Decoder turns text into percent-encoding and back, in your browser. Choose whether you are encoding a single value, such as a search term, or a whole link that should keep its slashes and question marks. Options cover + or %20 for spaces and encoding each line on its own. When decoding, broken parts such as a stray % are left as typed instead of causing an error, and a table shows the name and value of every query string parameter. Nothing you paste is uploaded.
Why URLs Need Encoding
A URL is allowed to contain only a short list of characters: letters, digits, and a few marks such as - _ . and ~. Everything else is either not allowed at all or already has a job. The question mark starts the query string, the ampersand separates parameters, the equals sign joins a name to its value, and the hash points to a part of the page. If your data contains one of those, the receiving server cannot tell whether you meant the character or the structure.
Percent-encoding fixes this. Each unsafe character is replaced by a percent sign and the two-digit hexadecimal code of its byte. A space is byte 32, which is 20 in hexadecimal, so it becomes %20. Characters outside basic English are first converted to UTF-8, and each of their bytes is written out, which is why one letter can turn into six characters.
A Value or a Whole URL?
This is the choice that trips people up, because JavaScript has two functions that look alike. encodeURIComponent is for a single piece of text. encodeURI is for an address that already has its structure in place. The tool calls them "A value" and "A whole URL".
| Input | As a value | As a whole URL |
|---|
| hello world | hello%20world | hello%20world |
| a&b=c | a%26b%3Dc | a&b=c |
| https://x.com/a b?q=1 | https%3A%2F%2Fx.com%2Fa%20b%3Fq%3D1 | https://x.com/a%20b?q=1 |
| café | caf%C3%A9 | caf%C3%A9 |
Use the value mode when the text is going inside a link, for example the address you pass as a redirect parameter. Use the whole URL mode when someone gave you a link with spaces in it and you only want it to be valid.
Frequently Asked Questions
What is the difference between %20 and + for a space?
%20 is the standard percent-encoding of a space and works everywhere in a URL. The + sign means a space only in form data (application/x-www-form-urlencoded), which is what you get from an HTML form or a query string. In a URL path, a + is a real plus sign. When in doubt, use %20.
Which one should I use: a value or a whole URL?
If you are putting text inside a link, such as a search term, a redirect address or a name, choose "A value". That encodes / ? & = and # too, so the text cannot break the link. If you already have a complete address with spaces or accented letters in it and only want it made safe, choose "A whole URL", which leaves the structure alone.
Why does my link now contain %2520?
It has been encoded twice. The first pass turned a space into %20, and the second pass turned the % into %25, giving %2520. Decode it once to get %20 back, and make sure only one step in your code or tool encodes the value.
Why does decoding show an error about a part that could not be decoded?
A % must be followed by two hex digits, so text like 100% or %zz is not valid encoding. Instead of throwing everything away, the tool decodes what it can and leaves the broken part as you typed it, with a note telling you how many places were skipped.
How are non-English letters and emoji encoded?
They are first turned into UTF-8 bytes, and every byte is written as %XX. So ü becomes %C3%BC, the Hindi letter क becomes %E0%A4%95, and the smiling face emoji becomes %F0%9F%98%80. Modern browsers show the readable form in the address bar but send the encoded form.
Is there a maximum URL length?
The standards do not set one, but in practice about 2,000 characters is a safe limit for links that will be shared or opened by many programs. Browsers accept more, but some servers, proxies and email clients cut long URLs. Encoded text is longer than the original, since every special character becomes three or more.
Is the text I paste sent to a server?
No. Encoding and decoding use functions built into your browser, so nothing is uploaded or stored.