CalcKit CalcKit
My Calculators
Sign in Sign up

URL Encoder / Decoder

Encode and decode URLs online: percent-encode text or a whole URL, decode %20 and other escapes, and see a URL's parts and query parameters. In your browser.

URL Parts

Enter a full URL (https://…) in either field to see its parts and query parameters here.

Query Parameters

NameValue (decoded)

URL Encoder / Decoder: A Quick Guide

What is URL encoding?

A URL may only contain a small set of ASCII characters, and some of them have a job: / separates the path, ? starts the query, & and = separate its parameters, and # starts the fragment. URL encoding, also called percent-encoding, writes any other character as a % followed by two hex digits, one escape for each byte of its UTF-8 form. A space becomes %20, and é, two bytes in UTF-8, becomes %C3%A9. Decoding turns the escapes back into the text.

How to use the URL Encoder / Decoder

  1. To encode, type or paste text in the Decoded Text field. The encoded version appears in the URL Encoded field as you type.
  2. To decode, paste an encoded text or URL in the URL Encoded field. The readable text appears in the Decoded Text field.
  3. Choose how to encode with Encode as (see below). Changing it converts again from the field you typed in last.
  4. Read the URL Parts. When either field holds a full URL, its protocol, host, path, query and fragment are listed below, with every query parameter decoded.
  5. Copy either field with its Copy button.

A broken escape, such as a % without two hex digits after it, marks the field in red and says where it is. Everything runs in your browser, and nothing you enter is sent anywhere.

The four ways to encode

Every option encodes spaces, accents, emoji and other non-ASCII characters. They differ in which ASCII punctuation they leave as it is:

  • Component leaves letters, digits and - _ . ! ~ * ' ( ). Use it for one value inside a URL, such as a query parameter or a path segment. It is JavaScript's encodeURIComponent().
  • Whole URL leaves the same, plus ; , / ? : @ & = + $ #. Use it for a complete URL that contains spaces or accents. It is JavaScript's encodeURI().
  • RFC 3986 leaves letters, digits and - _ . ~. It is the strict encoding most other languages use: PHP's rawurlencode() and Python's quote(s, safe="").
  • Form data (+) leaves letters, digits and - _ . *, and writes a space as +, as HTML forms send query strings and bodies. It is JavaScript's URLSearchParams.

PHP's urlencode() and Python's quote_plus() are close to Form data, but also encode *, and Python leaves ~ as it is. Decoding is the same for every option, except that Form data also reads a + as a space.

Common encoded characters

CharacterEncodedCharacterEncoded
space%20:%3A
!%21;%3B
"%22<%3C
#%23=%3D
$%24>%3E
%%25?%3F
&%26@%40
'%27[%5B
(%28]%5D
)%29line break%0A
*%2Aé%C3%A9
+%2Bü%C3%BC
,%2C€%E2%82%AC
/%2F😀%F0%9F%98%80

The parts of a URL

For this URL, the URL Parts card lists the parts below:

https://user@example.com:8080/docs/page?lang=en&q=url+encoding#intro

  • Protocol: https
  • Username: user (rare, and shown only when present, like a password)
  • Host: example.com, and the Port: 8080 when one is given
  • Path: /docs/page
  • Query: lang=en&q=url+encoding, split into its parameters, lang is en and q is url encoding
  • Fragment: intro, the part after the #, which the browser keeps to itself

The parameter values are decoded the way a web server reads them, so a + in the query is a space there.

Examples

  1. A search term in a query. With Component, coffee & cake encodes to coffee%20%26%20cake, so the & can't be mistaken for the start of another parameter. With Form data it is coffee+%26+cake.
  2. A link with accents and spaces. With Whole URL, this link:
    https://example.com/café menu?size=large
    encodes to this, keeping the /, ? and = that make it a URL:
    https://example.com/caf%C3%A9%20menu?size=large
  3. An encoded link. Pasted in the URL Encoded field, this text:
    https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Dcaf%C3%A9
    decodes to https://example.com/search?q=café.

Frequently asked questions

What does %20 mean in a URL?

%20 is an encoded space: 20 is the space character's code in hex. In query strings sent by HTML forms, a space is written as + instead, and both mean the same to a server reading a query.

What is the difference between encodeURI and encodeURIComponent?

encodeURI() is for a whole URL: it leaves the characters that give a URL its structure, such as /, ?, & and #. encodeURIComponent() is for one piece of a URL, such as a parameter's value, and encodes those characters too, so a value containing & or / stays one value. Choose Whole URL or Component above to get each.

Why does my URL contain %2520?

It was encoded twice. %25 is an encoded %, so %2520 is %20 encoded again. Decode it, then paste the result in the URL Encoded field and decode it once more to get the space back.

Why does decoding fail with "isn't UTF-8"?

Today URLs encode text as UTF-8, but some older sites used Latin-1 (ISO-8859-1), where é is the single byte %E9 instead of %C3%A9. Those bytes aren't valid UTF-8, so they can't be decoded as text here.