bytekit

URL Encoder & Decoder

Encode and decode URLs and URL components correctly. Everything runs in your browser, so nothing is uploaded anywhere.

  • Free
  • No sign-up
  • Runs in your browser

encodeURI(): Encodes unsafe characters but keeps the characters that give a URL its structure (: / ? # & = @ + $ , ;). Use this for a complete address.

What it is for

Web addresses can only contain a limited set of characters. URL encoding replaces everything else with a percent sign and a code, such as %20 for a space, so a link or a query value never breaks.

  • Add a search phrase or a name with spaces to a query string.
  • Read an address full of %20 and %2F codes.
  • Fix a link that breaks because a value contains &, ? or #.
  • Prepare a value for a redirect or callback parameter.

How to use it

  1. Choose Encode or Decode.
  2. Choose Full URL for a complete address, or URL component for one piece of a URL, such as a single query value.
  3. Paste your text. The result updates as you type.
  4. Copy the result, or use Swap to run it back the other way.

Examples

Encode one value (URL component)

You enter

hello world & more=1

You get

hello%20world%20%26%20more%3D1

The & and = are encoded as well, so this value cannot break the address it is placed in.

Encode a complete address (Full URL)

You enter

https://example.com/a b?q=ü&x=1#top

You get

https://example.com/a%20b?q=%C3%BC&x=1#top

The structure (://, ?, &, =, #) is kept, so the link still works.

Decode

You enter

%E2%9C%93%20done

You get

✓ done

Limits and disclaimers

  • Pick the right scope. Running a whole URL through URL component encoding turns https:// into https%3A%2F%2F, and it stops working as a link.
  • Encoding text that is already encoded encodes the % signs again (double-encoding). Decode first if you are unsure.
  • Decoding fails on a stray % that is not followed by two valid hexadecimal digits.
  • Encoding makes an address safe to send. It does not make the content private or trustworthy.

ByteKit is provided as is, for convenience. Check any result that matters before you use it in production, and keep passwords, keys and personal data out of any website you do not control.

encodeURI() vs encodeURIComponent(): which one should I use?

Both functions replace unsafe characters with percent-encoded sequences, but they answer different questions, so they are not interchangeable.

Full URL: encodeURI()

Use it for a complete address. It keeps the characters that give a URL its structure, so the link still works afterwards:

: / ? # [ ] @ ! $ & ' ( ) * + , ; =

URL component: encodeURIComponent()

Use it for one piece of a URL, such as a query parameter value. It also encodes the structure characters above, so a value can never break the URL it is placed in. It leaves only letters, digits and:

- _ . ! ~ * ' ( )

Same input, different results

Input:

https://example.com/search?q=café & tea#top

With encodeURI() the structure survives:

https://example.com/search?q=caf%C3%A9%20&%20tea#top

With encodeURIComponent() everything is encoded, and the result is no longer a working link:

https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Dcaf%C3%A9%20%26%20tea%23top

  • Never run a whole URL through component encoding, because https:// becomes https%3A%2F%2F and stops working as a link.
  • Never place a value that contains & or = through full-URL encoding, because those characters would be read as part of the URL's structure.
  • Decoding follows the same rule: decodeURI() leaves encoded structure characters such as %2F alone, while decodeURIComponent() decodes everything.
  • Encoding text that is already encoded encodes the % signs again (double-encoding), so decode first if you are unsure.

Questions people ask

Why is a space sometimes %20 and sometimes +?

%20 is the general form and works everywhere. A plus sign means a space only in HTML form data. ByteKit uses %20 by default, and the Form style option under URL component switches to +.

Which one should I use, Full URL or URL component?

Use Full URL for a whole address and URL component for a single value that you will place inside an address.

Does it handle accents and emoji?

Yes. They are converted using UTF-8, which is the standard for web addresses.