oktools

URL Encoder & Decoder

Percent-encode text for a query string or path segment (urlencode) and decode URL-encoded strings back to readable text. Encode a single component or a whole URL, choose strict RFC 3986, and decode form-encoded values where + means a space. Everything runs in your browser.

Mode:
Encode as:

Component encodes everything but letters, digits and - _ . ~ ! ' ( ) *, like encodeURIComponent.

0

0

How it works

Percent-encoding replaces a byte with a % sign and its value as two hexadecimal digits. Text is written as UTF-8 first, so a character outside ASCII becomes two, three or four groups: é is %C3%A9, not one escape. In Component mode the page calls encodeURIComponent, which leaves alone only letters, digits, - _ . ~ and the five characters ! ' ( ) * that JavaScript has always passed through. Everything else, including & = ? / and the space, is escaped, which is right for a single query value, a path segment or a cookie value.

Whole URL mode calls encodeURI instead. It escapes the same spaces and non-ASCII characters but keeps : / ? # & = + $ , ; @ and the rest of the characters that give an address its structure, so a complete URL stays routable instead of becoming one long path segment. Strict RFC 3986 applies on top of either mode and encodes ! ' ( ) * as well, which is what PHP’s rawurlencode and Python’s quote with an empty safe set produce — the form for a server or a signing scheme that treats those five as reserved.

Decoding runs decodeURIComponent over the text, after turning each + into a space when Form-encoded is ticked, because application/x-www-form-urlencoded writes spaces that way and a real plus as %2B. When decoding fails the page works out why: it scans for the first % that is not followed by two hex digits and names its position, and if every escape is well formed it reports that the bytes are not valid UTF-8, which usually means the text was encoded in another character set or a multi-byte sequence was cut in half.

Examples

Encode a query value with an ampersand

The ampersand, colon, percent sign and question mark would each be read as URL punctuation, so all four are escaped along with the spaces. Paste the result after q= and the server receives the original text.

Input
Tom & Jerry: 100% fun?
Output
Tom%20%26%20Jerry%3A%20100%25%20fun%3F

Encode a whole URL without breaking it

Whole URL leaves the scheme, the slashes, ? and & in place and escapes only the spaces and the é, which becomes its two UTF-8 bytes. Component mode would have produced https%3A%2F%2Fexample.com%2Fsearch%3Fq%3D…, which no server would route.

Input
https://example.com/search?q=café au lait&page=2
Output (Whole URL)
https://example.com/search?q=caf%C3%A9%20au%20lait&page=2

Decode a form-encoded query string

With Form-encoded ticked the + in Ann+Lee is a space and the %2B is a literal plus. Untick it and the output reads name=Ann+Lee&note=2+2=4, which is right for a value that came from a path rather than a form.

Input
name=Ann+Lee&note=2%2B2%3D4
Output (Form-encoded)
name=Ann Lee&note=2+2=4

Find a stray percent sign

A % at the end of a value, or one followed by anything but two hex digits, makes the whole string undecodable. The position is counted from 1, so it can be found in the input, and the fix is to write the sign as %25.

Input
discount=100%
Result
Invalid escape "%" at position 13 — a % must be followed by two hex digits. Encode a literal percent sign as %25.

Supported formats

  • Component encoding (encodeURIComponent)Escapes everything except A–Z, a–z, 0–9, - _ . ~ and ! ' ( ) *. The right form for one query parameter value, one path segment or one cookie value.
  • Whole-URL encoding (encodeURI)Keeps : / ? # & = + $ , ; @ and the unreserved set so an entire address stays valid, and escapes spaces, quotes, angle brackets and every character outside ASCII.
  • Strict RFC 3986Adds %21 %27 %28 %29 %2A for ! ' ( ) * in either mode, matching PHP’s rawurlencode and Python’s urllib.parse.quote with safe set to an empty string.
  • UTF-8 percent escapesText outside ASCII is encoded as its UTF-8 bytes: %C3%A9 for é and %E2%82%AC for €, which is what every modern browser sends and RFC 3987 describes.
  • Form-encoded decodingReads application/x-www-form-urlencoded, where + is a space and %2B a plus, as sent by HTML forms and most OAuth token endpoints.

Use cases

  • Build a query string by handEncode each value on its own in Component mode and join them with = and &; the result is what curl or fetch would send for that parameter.
  • Read an encoded URL from a log or a redirectPaste a redirect_uri, a return_to or a tracking link to see the address inside it, decoding a second time if %25 sequences remain.
  • Encode a path segment that contains a slashA file name or an ID with / in it has to travel as %2F or the router will split it; Component mode does that, Whole URL deliberately does not.
  • Match a strict signing schemeOAuth 1.0 signatures and AWS Signature Version 4 require ! ' ( ) * to be escaped; compare the default output with Strict RFC 3986 to see the difference before signing.
  • Decode a form body from developer toolsThe Payload tab shows a submission as name=Ann+Lee&…; decode it with Form-encoded ticked to read the values as the server will.

Limitations

  • The URL is not parsed into partsThe page encodes or decodes the text as one string. It does not split an address into host, path and parameters or encode each query value separately; paste the values one at a time for that.
  • Whole URL cannot repair a broken addressencodeURI escapes spaces and non-ASCII text but leaves an unescaped & or # inside a value alone, because it cannot tell structure from data. Encode such values in Component mode before assembling the URL.
  • Only UTF-8 is decodedA legacy %E9 standing for é in Latin-1 is reported as invalid UTF-8 rather than decoded. Text in another character set needs a tool that knows which one it was.
  • No IDN or punycodeA host name with accented letters is percent-encoded like any other text, not converted to the xn-- form a browser would send; use a punycode converter for the host part.
  • Double encoding is undone one layer at a timeA %2520 decodes to %20 and stops there. Paste the output back in and decode again until no %25 sequences are left.

Frequently asked questions

What is URL encoding?

URL encoding, or percent-encoding, replaces characters that have a reserved meaning in a URL with a percent sign and their hexadecimal byte value — a space becomes %20, an ampersand %26. It is what lets a value containing & or ? travel inside a query string without being mistaken for the URL’s own punctuation.

Which characters have to be encoded?

Everything outside the unreserved set of A-Z, a-z, 0-9 and - _ . ~ may need encoding, and the reserved characters : / ? # [ ] @ $ & + , ; = do whenever they appear inside a value rather than as URL structure. Five more are reserved by RFC 3986 but left alone by JavaScript’s encodeURIComponent: ! ' ( ) *. Most servers accept them raw, so they are left alone here too unless you tick Strict RFC 3986, which encodes them the way PHP’s rawurlencode and Python’s quote(safe="") do. Non-ASCII characters are encoded as their UTF-8 bytes, which is why a single accented letter becomes two percent groups.

Should I encode the whole URL or just one parameter?

Usually just the value. The Component mode works like encodeURIComponent — right for a single query parameter or path segment, which is what you almost always have. Encoding a complete address that way turns its slashes and colons into %2F and %3A and produces something no server will route. For a whole URL pick Whole URL, which works like encodeURI: it encodes spaces and non-ASCII characters but keeps : / ? # & = and the rest of the structure intact.

Why is a space sometimes %20 and sometimes a plus sign?

Both appear, in different places. Percent-encoding proper uses %20, and that is what you get here. The plus sign comes from HTML form submission, where application/x-www-form-urlencoded writes a space as +. A decoder has to know which convention produced the text, since a literal plus in a form-encoded value is itself written %2B. Tick "Form-encoded (+ means space)" when decoding a query string that came from a form.

Why does my decoded text come out as gibberish or fail?

Two usual causes: the text was encoded twice, so you need to decode it again — a %2520 is an encoded %20 — or it contains a stray percent sign that is not part of a valid group, which makes the whole string invalid. The error here tells you the position of the first bad escape. Double encoding is the common one and shows up as visible %25 sequences.

Is the text I encode sent anywhere?

No. The whole tool is JavaScript running in your own browser, so nothing you type or paste is sent over the network, written to a log or attached to an analytics event. You can confirm it by opening the network tab and watching it stay empty while you work.