DevKitHub

Encoding & Conversion

URL Encoder and Decoder

Encode text for safe use in a URL, or decode percent-encoded text back to readable form. Choose component mode for a single query value, or URI mode for a whole URL.

1 line
1 line

This tool runs entirely in your browser. Your input is never uploaded, stored or logged.

How it works

Percent-encoding replaces a byte with a % followed by its two hex digits. Non-ASCII characters are converted to UTF-8 first and each byte encoded separately, which is why a single accented character becomes two escapes and an emoji becomes four.

The two modes differ only in which characters they consider reserved. Component mode escapes the delimiters — / ? : @ & = + $ and # — because inside a query value those characters would otherwise end the value and start something else. URI mode leaves them alone so a complete URL survives intact.

Choosing the wrong mode is the usual cause of a broken link. Encoding a whole URL in component mode turns https://example.com into https%3A%2F%2Fexample.com, which is correct if that URL is a parameter of another URL and wrong if it is the URL you meant to visit.

Common problems

Every example below is run against this tool in our test suite, so what it says here is what the tool actually does.

Malformed percent-encoding

100%
Why:
A literal % not followed by two hex digits. Percent starts an escape sequence, so it cannot appear on its own.
Fix:
Encode a literal percent sign as %25.

Malformed percent-encoding

%E0%A4
Why:
A multi-byte UTF-8 sequence that was cut short, usually by truncating an already-encoded string.
Fix:
Re-encode from the original text rather than trimming encoded output.

Frequently asked questions

What is the difference between the two modes?
Component mode escapes reserved delimiters such as / ? : @ & = + $ and #, which is what you want for a single query value. URI mode leaves those characters intact so a complete URL stays usable.
Why does decoding fail with "malformed percent-encoding"?
A literal "%" that is not followed by two hexadecimal digits, or a multi-byte escape that was cut short, cannot be decoded. Encode a literal percent sign as %25.

Last updated