URL Escape Online Encoder & Decoder

What is URL Encoding

URL encoding, also known as percent-encoding, is a mechanism for converting characters into a format that can be safely transmitted inside a URL.

Purpose of Encoding

  • Complying with the URL specification: URLs may only contain a specific character set: letters, digits and a few special characters (such as -_.~). Characters outside this set must be encoded before they can appear in a URL. For example, a space is not allowed literally in a URL and is encoded as %20.
  • Preventing ambiguity: Some characters have special meanings in a URL, such as /, ? and &. Without encoding they can break URL parsing. For example, to pass a parameter value that itself contains a question mark ?, the question mark must be encoded, otherwise it would be mistaken for the query-string delimiter.

Encoding Rules

  • For characters that require encoding, convert the ASCII value to hexadecimal and prefix it with a % sign. For example, the ASCII value of # is 35, which is 23 in hexadecimal, so # is encoded as %23.
  • Reserved and unreserved characters: Reserved characters are those used to delimit different parts of a URL (such as /, ?, :, #, [, ], @, !, $, &, ', (, ), *, +, ,, ;, =) plus the character that controls encoding itself (%). When they are not used for their special purpose, they generally need to be encoded. Unreserved characters are letters, digits and -_.~; these can appear in a URL directly without encoding.

Use Cases

  • Passing URL parameters: When parameters are passed through a URL, values containing special or non-ASCII characters must be URL-encoded. For example, on a search page, if the keyword entered by the user contains spaces or other special characters, it must be encoded before being appended to the URL, as in https://www.example.com/search?q=hello%20world, where "hello world" becomes hello%20world after encoding.
  • Form submission: When data is submitted through an HTML form, the browser automatically URL-encodes field values containing special characters before sending them to the server. For example, in a login form, if the username contains special characters, the browser encodes it before including it in the request.
  • AJAX requests: When making AJAX requests in JavaScript, URLs or parameters containing special characters also need to be URL-encoded to ensure the server parses the request correctly.
  • Go Implementation

    url.QueryEscape("https://www.cyeam.com")
    Character URL-Encoded Description
    Space %20 One of the most common encodings on the web, replaces a space
    Slash %2F Separates URL path segments (as in https%3A%2F%2Fexample.com )
    Question mark %3F Marks the start of the query string (as in ?key=value )
    Equals sign %3D Joins keys and values in query parameters (as in key%3Dvalue )
    Ampersand %26 Separates multiple query parameters (as in key1%3Dvalue1%26key2%3Dvalue2 )
    Hash %23 Used for URL fragments (as in #section )
    Plus sign %2B Represents a space or a literal plus (common in form submissions)
    Percent sign %25 Escapes itself (because URL encoding starts with % )
    Comma %2C Separates parameters or path parts (e.g. CSV download links)
    Colon %3A Separates the URL scheme and port (as in https%3A// )
    Semicolon %3B Used to separate parameters in some URL formats
    Greater-than sign %3E Encoding of the > symbol
    Less-than sign %3C Encoding of the < symbol
    Exclamation mark %21 Encoding of the ! symbol
    Asterisk %2A Encoding of the * symbol
    Single quote %27 Encoding of the ' symbol
    Double quote %22 Encoding of the " symbol
    Parentheses %28 (left), %29 (right) Encoding of the ( and ) symbols
    Square brackets %5B (left), %5D (right) Encoding of the [ and ] symbols
    Curly braces %7B (left), %7D (right) Encoding of the { and } symbols
    Vertical bar %7C The `|` symbol
    Tilde %7E Encoding of the ~ symbol
    At sign %40 Encoding of the @ symbol (common for email addresses in URLs)
    Dollar sign %24 Encoding of the $ symbol
    Pound sign %A3 Encoding of the £ symbol (may vary by charset)

    Feedback