Skip to content
Technologydeveloper

URL Encoder and Decoder

URL encoding and decoding, with the component and whole-URI variants separated. Encoding a whole URL with the component function breaks it, because that function escapes the slashes and colons that make it a URL.

Also called: percent encoding, uri encoder.

Direction
Encode
Result
search%3Fq%3Dtax%20rate%26year%3D2026

search%3Fq%3Dtax%20rate%26year%3D2026. 5 characters were changed of 27. The component function escapes reserved characters including slashes and colons, which is right for a value and wrong for a whole URL.

Input length
27
Output length
37
Characters encoded
5
On the two functions
The component function escapes reserved characters including slashes and colons, which is right for a value and wrong for a whole URL.
On privacy
This runs in your browser. Nothing you paste is sent anywhere, which matters for anything sensitive.
Method and background

How this is calculated

Percent encoding replaces reserved and unsafe characters with a percent sign and their hexadecimal byte value. The distinction between the two functions is the one that causes bugs: the component function escapes everything reserved, including the slashes, colons and ampersands that give a URL its structure, which is correct for a query parameter value and wrong for a whole address. The URI function preserves those, which is correct for a whole URL and insufficient for a value being placed into one.

reserved and unsafe characters become a percent sign and their hex byte value
XX
Hex byte value

Worked examples

Each of these is asserted on every build. If a change to the engine ever moved one of these answers, the build would fail before the page could print it.

encoding a query string

Text
search?q=tax rate&year=2026
Direction
Encode
Encode
A component, encoding reserved characters

Resultsearch%3Fq%3Dtax%20rate%26year%3D2026

The component function escapes ? = & and the space

Open this example

the URI function preserves structure

Text
search?q=tax rate&year=2026
Direction
Encode
Encode
A whole URI, preserving structure

Resultsearch?q=tax%20rate&year=2026

boundary: only the space is escaped

Open this example

Method and limits

What it assumes

  • UTF-8 encoding, which multi-byte characters expand under.

What it deliberately does not model

  • Space encodes as %20 here; form submissions use a plus sign instead, which is a different convention.
  • Double encoding is a common bug and this does not detect it.

Formula version 1.0.0 · definition 1.0.0 · United States · Report a problem with this calculator

Frequently asked questions

Which function should I use?
The component function for a value going into a query parameter, since it escapes the ampersands and equals signs that would otherwise break the query. The URI function for a whole address.
Why did encoding my URL break it?
You used the component function, which escapes slashes and colons. Those characters are the structure of a URL, so escaping them turns it into a meaningless string.