Toolvito

Works on this device

URL Encoder & Decoder

Encode text so that it is safe inside a web address, or decode a percent-encoded address back to plain text. The result shows as you type. The text is converted in your browser and is not sent to a server.

Your text

Every character counts, also spaces and line breaks.

More options

UTF-8 is the standard for URLs. Some old pages use the other two.

Your text is converted in this browser. It is not sent to a server.

The result will show here

Type or paste some text, or choose Try an example.

How to use the URL encoder and decoder

  1. Choose what to do: encode text, decode text, split a URL into its parts, or build a query string.
  2. Type or paste your text. The result shows as you type.
  3. For encoding, choose the rule. Use one part of a URL for a value, a name or a file name. Use a whole URL only for a complete address. Use form data when a space must become +.
  4. For decoding, tick Read + as a space when the text comes from a form or a query string.
  5. Choose Copy output or Download output to keep the result.

How percent-encoding works

A URL may hold only a small set of characters. Any other character is first turned into bytes (UTF-8 is the standard) and each byte is written as % and two hexadecimal digits. A space becomes %20, and é becomes %C3%A9. This is called percent-encoding, and RFC 3986 defines it.

Some signs have a job in a URL: / parts the path, ? starts the query, & and = part the names and values, and # starts the fragment. Inside a value these signs must be encoded, or the URL means something else. When you encode a whole URL they must stay.

  • One part of a URL (RFC 3986): only letters, digits and - . _ ~ stay. This is the safe choice for a value or a name.
  • As JavaScript encodeURIComponent: the same, but ! * ' ( ) also stay.
  • A whole URL (as JavaScript encodeURI): the signs : / ? # & = + $ , ; @ also stay. A % sign becomes %25, so do not use it on a URL that is already encoded.
  • Form data: letters, digits and * - . _ stay, and a space becomes +. Web forms send their fields this way.

Worked example

The text Zoë & Co: 100% "fun"? encoded as one part of a URL is Zo%C3%AB%20%26%20Co%3A%20100%25%20%22fun%22%3F. The letter ë is the two bytes C3 AB in UTF-8, so it becomes %C3%AB.

As form data the same text is Zo%C3%AB+%26+Co%3A+100%25+%22fun%22%3F: each space is a +.

The URL https://example.com:8080/docs/a%20b.html?q=caf%C3%A9+au+lait&lang=en&lang=fr#part-2 has the scheme https, the host example.com, the port 8080, the path /docs/a%20b.html, the fragment part-2 and three query parameters. The value of q is café au lait, and lang is used twice.

Which function gives which rule

These functions give the same result as the rules on this page. Other functions, such as PHP urlencode, Python quote_plus and Go url.QueryEscape, also write a space as +, but they differ from the form rule in a few signs such as ~ and *.

Functions that follow each rule
Rule on this page Functions that give the same result
One part of a URL (RFC 3986) Python urllib.parse.quote(text, safe=""), PHP rawurlencode($text), C# Uri.EscapeDataString(text)
As JavaScript encodeURIComponent JavaScript encodeURIComponent(text)
A whole URL JavaScript encodeURI(url)
Form data JavaScript new URLSearchParams({ name: value }).toString(), Java URLEncoder.encode(text, StandardCharsets.UTF_8)

Limits you should know

  • Decoding is strict. A % that is not followed by two hexadecimal digits, and bytes that are not valid UTF-8, are reported with their place. Under More options you can ask the page to leave or replace them.
  • A + is read as a space only when you tick the box. In a path a + is a plus sign. In form data it is a space.
  • The page does not open the URL and does not check that the address exists or is safe.
  • When you split a URL, the parts are written the way browsers write them: the scheme and host in small letters, and names with letters outside ASCII in their xn-- form.
  • Text to encode can have up to 100,000 characters, text to decode up to 300,000, and a URL to split up to 20,000.
  • Characters are turned into bytes as UTF-8. ISO-8859-1 and Windows-1252 are offered for old pages only.

Related tools