JSONToonPro
Encoding tool

URL Encode

Percent-encode any text or URL using encodeURIComponent. Spaces become %20, slashes become %2F, and all special characters are converted to safe URL tokens. Everything runs in your browser.

100% client sideInstant resultNo data sent
Plain text / URL
0 chars
URL Encoded
Result appears here...

What Percent-Encoding Is

A URL is not free text. RFC 3986 allows only a small set of US-ASCII characters, and some of those are reserved as structural delimiters: the slash separates path segments, the question mark starts the query, the ampersand separates parameters, the equals sign splits a key from its value, and the hash begins the fragment. If your data contains any of those characters, the parser on the other end will read them as structure rather than content.

Percent-encoding is the escape mechanism. The character is converted to its bytes in UTF-8, and each byte is written as a percent sign followed by two hexadecimal digits. A space becomes %20. Characters outside ASCII take multiple bytes, so the euro sign becomes %E2%82%AC, three bytes and therefore three escape sequences.

Characters That Are Never Encoded

The unreserved set is guaranteed safe anywhere in a URL and must be left alone, because encoding it changes nothing semantically but breaks string comparison and cache keys.

Unreserved (RFC 3986): A-Z a-z 0-9 - _ . ~
 
encodeURIComponent additionally leaves untouched: ! * ' ( )
These are legacy exceptions kept for compatibility.

encodeURI vs encodeURIComponent

This is the single most common source of broken links. The two functions differ in one respect: whether they treat reserved delimiters as structure to preserve or as data to escape.

  • encodeURI is for a whole URL. It leaves the delimiters : / ? # [ ] @ ! $ & ' ( ) * + , ; = intact so the address still parses.
  • encodeURIComponent is for one piece of a URL, a single query value or path segment. It escapes those delimiters, because inside a value they are data.
Input: https://example.com/a b?q=1&r=2
 
encodeURI:
https://example.com/a%20b?q=1&r=2
structure preserved, only the space escaped
 
encodeURIComponent:
https%3A%2F%2Fexample.com%2Fa%20b%3Fq%3D1%26r%3D2
everything escaped, safe to nest inside another URL

The rule of thumb: if you are building a URL, use encodeURI once at the end or, better, build it with a URL object. If you are inserting a value into a URL, always use encodeURIComponent on that value alone.

Worked Example: A URL Inside a Parameter

Redirect parameters are where this bites hardest. Suppose you want to pass an entire search URL as the value of a redirect parameter.

Value to carry:
https://example.com/search?q=hello world&lang=en
 
Encoded as a component:
https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Dhello%20world%26lang%3Den
 
Final URL:
https://app.example.com/go?redirect=https%3A%2F%2Fexample.com
%2Fsearch%3Fq%3Dhello%20world%26lang%3Den
 
Without encoding, &lang=en would be read as a parameter of the
outer URL and the redirect value would silently truncate.

Form Encoding: Why Spaces Become Plus

HTML form submissions use the media type application/x-www-form-urlencoded, which predates RFC 3986 and has one important quirk: a space is written as a plus sign rather than %20. Everything else follows percent-encoding as normal, and a literal plus sign in the data is encoded as %2B so the two cannot be confused.

Value: hello world & more
Percent-encoded: hello%20world%20%26%20more
Form-encoded: hello+world+%26+more
 
Both are valid. The receiver must know which one it is reading.

Servers usually apply form decoding to query strings as well, which is why %20 and plus both tend to work in practice. Do not rely on it: a plus sign that survives into a value processed by a strict RFC 3986 parser stays a plus sign, and a password or search term silently changes meaning.

Percent-Encoding Reference Table

These are the characters you meet most often when working with query strings, path segments, and form data. Each one is replaced by a percent sign followed by the two hexadecimal digits of its byte value.

CharacterEncodedName
space%20Space
!%21Exclamation mark
"%22Double quote
#%23Hash / fragment delimiter
$%24Dollar sign
%%25Percent sign
&%26Ampersand / parameter separator
'%27Apostrophe
(%28Left parenthesis
)%29Right parenthesis
*%2AAsterisk
+%2BPlus sign
,%2CComma
/%2FSlash / path separator
:%3AColon / scheme separator
;%3BSemicolon
=%3DEquals / key value separator
?%3FQuestion mark / query start
@%40At sign
[%5BLeft square bracket
]%5DRight square bracket
newline%0ALine feed
tab%09Horizontal tab

Working on something related? Browse every free developer tool on the site, including a URL decoder, Base64 encoder, HTML encoder, and query string helpers. Everything runs entirely in your browser, so nothing you paste is ever uploaded.

Frequently asked questions

4 answers
URL encoding (also called percent-encoding) converts characters that are not allowed in a URL into a safe format. Each unsafe character is replaced with a percent sign followed by two hexadecimal digits representing the character's ASCII or UTF-8 byte value. For example, a space becomes %20, an ampersand becomes %26, and a forward slash becomes %2F.

More JSON Tools

About URL Encoding

URL encoding is a fundamental part of working with HTTP. Query parameters, form submissions, and API calls all rely on percent-encoding to safely carry arbitrary text inside a URL. This tool uses the browser's native encodeURIComponent function, which handles Unicode correctly by first converting characters to their UTF-8 byte sequences and then percent-encoding each byte. It is the standard choice for encoding individual query parameter values before appending them to a URL.