Skip to content
FmtTools

URL Encoder and Decoder

Percent-encoding with the context made explicit — component, path, query value, whole URI or form body — plus canonicalisation, double-encoding detection and a URL inspector that resolves every RFC 3986 part.

Context

Encoding context

encodeURIComponent: JS component encoder — keeps - _ . ! ~ * ' ( ) and escapes /, so paths break. Percent-encoding is context dependent — the same string needs a different escape set in a path, a query value and a form body, which is why “URL encode” boxes produce wrong output so often.

Text to encode

Characters 49UTF-8 bytes 51

Percent-encoded

https%3A%2F%2Fexample.com%2Fsearch%3Fq%3DC%2B%2B%20%26%20%22quotes%22%2F%E2%82%AC%23tag
Escapes 16Length 49 → 87

What changed and why

  • infonon-asciiNon-ASCII characters were encoded as UTF-8 byte sequences.

    RFC 3986 §2.5 only allows percent-encoded octets to stand for characters whose encoding is known, and §7.2 says the encoding must be UTF-8 unless another protocol states otherwise. Windows-1252 or Shift-JIS payloads produce the same % escapes with different numbers, which is why "mojibake" URLs happen when the two sides disagree.

  • infoslash-encoded"/" was escaped to %2F because component mode treats the whole string as one path segment.

    Some web servers and WAFs reject %2F in a path (IIS and Apache both normalise it before routing), so route-style values sometimes must stay unescaped — encode each segment separately instead.

Input characters
49
Input UTF-8 bytes
51
Output characters
87
Escapes written
16

Each escape is 3 characters

Bytes behind escapes
18
Characters kept literal
33
Growth
+77.6%

Correct escaping depends on where in the URL the text sits

Percent-encoding replaces a character with % and two hex digits, but which characters may stay literal depends on the component. A ? is legal inside a path segment and starts a query after it; & separates parameters and must be escaped inside a value; + means a literal space only in application/x-www-form-urlencoded, and never in a query value produced by encodeURIComponent. One escaping mode cannot be right for all five positions, which is why this tool makes you choose.

Decoding is not the mirror image. A decoder that runs twice is a vulnerability: %252e%252e%252f decodes once to ../ and a second pass turns it into a traversal the filter never saw. The decoder therefore reports when the input itself contains an escape of a percent sign — a double-encoding signature — instead of quietly normalising it, and it can canonicalise escapes to uppercase and strip percent-encoding of unreserved characters, the normalisation that RFC 3986 §6.2.2 describes.

The inspector splits any URL into scheme, authority, userinfo, host, port, path, query and fragment using the generic grammar of §3, lists each query parameter with its raw and decoded forms, marks repeated keys, and flags non-normal forms such as an empty port or a host that needs IDN encoding.

Modes, normalisation and inspection

  • Five escaping modes: component, path, query value, URI, form body
  • Uppercase or lowercase hex digits, with canonicalisation
  • Unreserved-character escapes removed per RFC 3986 §2.3
  • + treated as space only in form-body mode
  • Double-encoding detection with the affected substring
  • Invalid escape sequences reported rather than replaced
  • URL decomposition into all RFC 3986 components
  • Query parameter table with raw, decoded and repeated flags
  • Browser-resolved absolute URL where the input can be parsed
  • Encode and decode tabs deep-linked through the URL hash

How to percent-encode a URL or a value

  1. 1Choose the modeComponent for a single path segment or a query value, path when slashes should survive, query value when & and = must not, form body for POST payloads where + means space, and whole URI when escaping an already-assembled URL.
  2. 2Paste the textThe output shows how many characters were escaped and how the length changed, so an over-escaped value — a space becoming %2520 — is visible immediately.
  3. 3To decode, switch tabs and paste the escaped formThe decoder reports the escape count, whether the result still contains an encoded percent sign, and whether the string can be canonicalised without changing meaning.
  4. 4Inspect a full URL in the analysis panelComponents, parameters and their decoded values are listed with any normalisation issues, which is how you find a query key that appears twice with different values.

What each mode leaves literal

Character handling by mode, with the most common mistake in each row.
ModeKeeps literalEscapesTypical mistake if misused
ComponentA-Z a-z 0-9 - . _ ~ ! * ' ( )Everything else, including / ? & = #Paths look wrong because the slash became %2F.
Pathsub-delims, @, :, /? # % and unsafe bytesA ? inside a segment starts a query in the reader.
Query value/ ? and unreserved& = + # % and unsafe bytesAn unescaped & splits one value into two parameters.
Form bodyunreservedSpace becomes +, everything unsafe becomes %XXSending + in a query value where a literal plus was meant.
Whole URIstructural delimiters :/?#[]@&=+Only characters illegal in a URIFails to escape a value delimiter, so structure changes.

RFC 3986 §2.4 makes the point behind the table: a reserved character is indistinguishable from its percent-encoded form in meaning only when it stands for itself — which is a decision about position, not about the character.

Frequently asked questions

What is the difference between encodeURI and encodeURIComponent?

encodeURI assumes the input is a complete URL and leaves the structural characters alone; encodeURIComponent assumes it is one component and escapes #, ?, &, / and + too. This tool exposes the same distinction as five explicit modes, because the two JavaScript functions are the wrong granularity for query values.

Why is my space %20 in one place and + in another?

Percent-encoding of a space is %20 everywhere. + as a space is a form-encoding convention from application/x-www-form-urlencoded, and it only means space in that context — in a path segment or an OAuth signature base string a + is a literal plus. Mixing the two is the classic signature-failure cause.

What is double encoding and why does it matter?

Encoding an already-encoded string turns %20 into %2520. If a server decodes twice — for example a framework that normalises and then a handler that decodes again — input that a filter saw as harmless text becomes a control sequence. The decoder flags the %25 signature so you can see it rather than discover it in a log.

Should uppercase or lowercase hex be used?

Uppercase. RFC 3986 §6.2.2.1 defines percent-encoded octet normalisation as uppercase hex, and treats an escape of an unreserved character as equivalent to the character itself. Canonical output makes comparisons and caches behave, which is why the tool offers it explicitly.

Do I need to encode already-unicode domains?

Yes, to punycode (RFC 3492) before the hostname goes into a URL; percent-encoding applies to the path, query and fragment, not to the host. The inspector labels an international host so you can see which transformation it still needs.

Why is my query parameter arriving as an array?

Because the key appears more than once — repeated keys are legal and most frameworks collect them. The parameter table marks repeated keys, which is the fastest way to spot an accidental duplicate from a form plus a hand-appended value.

Why five escaping modes instead of one button?

Because the same string has several correct answers and picking the wrong one is a bug, not a style choice. encodeURIComponent keeps - _ . ! ~ * ' ( ) and escapes "/", so it breaks a path; encodeURI leaves the reserved characters that are legal as delimiters; a path segment may keep sub-delims while a query value must not, or the value can inject parameters; and a form body turns space into "+" where a path would need %20. Choose the mode, and the inspector splits the result into RFC 3986 components and flags a second pass of percent-encoding.