URL Encoder, Decoder & Query String Parser
Percent-encode or decode text for use in URLs, and take any URL apart into its host, path and query parameters. URLs often carry tokens, emails and internal hostnames, so it all runs locally in your browser and nothing is uploaded.
Encode or decode
Parse a URL or query string
What percent-encoding is
URLs may only contain a small set of characters. Anything else, and anything that would
otherwise be read as URL syntax, is written as a percent sign followed by the byte's two
hexadecimal digits: a space is %20, a slash
inside a value is %2F, and a non-ASCII
character becomes the percent-encoded bytes of its UTF-8 form —
é is
%C3%A9.
The characters that never need encoding are letters, digits and
- . _ ~. The rest depends on where in the
URL the text is going, which is why there are three styles here.
Which encoding style to use
- Component (
encodeURIComponent) for a single value you are placing inside a URL, such as a query parameter or a path segment. It encodes/ ? & = #so the value cannot break out of its slot. This is the right choice most of the time. - Full URL (
encodeURI) for an entire URL that just has a space or an accented character in it. It leaves/ ? & = #alone, so the URL keeps its structure. Applying it to a single value is a common bug: an ampersand in the value survives and splits the parameter. - Form (
application/x-www-form-urlencoded) is what HTML forms andURLSearchParamsproduce: the same as component encoding, except a space becomes+.
In code
// JavaScript
encodeURIComponent('a b/c&d') // 'a%20b%2Fc%26d'
const url = new URL('https://example.com/search')
url.searchParams.set('q', 'a b&c') // url.search === '?q=a+b%26c'
# Python
from urllib.parse import quote, quote_plus, urlencode
quote('a b/c', safe='') # 'a%20b%2Fc'
quote_plus('a b') # 'a+b'
urlencode({'q': 'a b&c'}) # 'q=a+b%26c'
# curl
curl --get --data-urlencode 'q=a b&c' https://example.com/search
Prefer URL and
URLSearchParams (or your language's equivalent)
over building URLs by string concatenation. They encode each part correctly, so you don't have to
decide by hand.
FAQ
Should a space be %20 or +?
%20 is valid everywhere. A
+ means "space" only in form-encoded data, which
in practice means query strings. In a path, a plus sign is just a plus sign, so
/c++/notes really does contain two plus characters.
When in doubt, use %20.
Why do I see %2520 in my URL?
That's double encoding. %20 was encoded a second
time, turning its percent sign into %25. It
usually means a value was encoded once by your code and again by a library or framework.
Decoding here flags this when the result still contains percent sequences.
Why does decoding fail with "not valid UTF-8"?
Percent-encoded bytes are only text if they form valid UTF-8. Older systems sometimes encode
in Latin-1, where é is a lone
%E9, which is not valid UTF-8 on its own.
The tool reports this rather than showing replacement characters.
Is anything after the # sent to the server?
No. The fragment stays in the browser. That's why the parser shows it separately, and why a
? inside a fragment is not part of the query.
How are repeated keys and arrays handled?
There is no single standard. The parser keeps every occurrence in order and marks repeated
keys, so tag=a&tag=b shows both. Conventions
such as a[]=1&a[]=2 are shown literally, since
how they're interpreted depends on the server framework.
Related tools
- HTML Entity Encoder & Decoder — Escape text for HTML, or decode entities exactly as a browser does.
- Format Identifier — Paste anything to find out what it is (a JWT, JSON, a certificate, Base64, a cron schedule and more), then open it in the right tool.