Skip to content

URL Encoder

Runs 100% in your browser — nothing is uploaded, nothing is stored.

Encoding happens entirely in your browser.

Percent-encoding looks like a solved problem until a query parameter containing an ampersand silently splits into two parameters and nobody notices for a week. This tool offers the four encodings that actually matter in practice and separates them explicitly, so you pick the one that matches where the value is going.

It also breaks an input URL into its decoded key and value pairs, which is the fastest way to see what a long query string is really carrying.

How to use this tool

  1. Paste the text, query value or full URL you want to encode.
  2. Choose the encoding matching the destination: Query value for a parameter, Whole URL when the input is already a complete URL, Path segment when the value is one segment of a path, Everything for strict RFC 3986.
  3. Click Encode. A short note above the input explains what the selected encoding preserves, so you can confirm the choice before copying the result.
  4. If the input contains a query string, the parameters are listed underneath as decoded key and value pairs.
  5. Load sample fills in a URL with a query string that contains a problem character, which shows the difference between the modes in one click.

What percent-encoding is for

A URL is a structured string, and several characters carry meaning as delimiters. The colon separates scheme from authority, the slash separates path segments, the question mark starts the query string, the ampersand separates parameters, and the equals sign separates each key from its value.

That structure breaks the moment a value contains one of those characters. If a search term is bed & breakfast, putting it raw into a query string produces ?q=bed & breakfast, which any parser will read as a parameter named q with value bed, plus an empty parameter named breakfast. The data is not corrupted in a way that throws an error — it is silently reinterpreted, which is worse.

Percent-encoding solves this by replacing each reserved character with a percent sign followed by two hexadecimal digits representing its byte value. A space becomes %20, an ampersand becomes %26, a question mark becomes %3F. A parser reading the encoded form sees a value with no structural characters in it and treats the whole thing as data.

The same rule applies outside URLs. Form bodies, cookies and some HTTP header values all use the same mechanism, and all have the same failure mode when a reserved character slips through unencoded.

The four encodings, and exactly what each preserves

The difference between them is which characters are treated as structure and therefore left alone. Everything else gets escaped.

Query value escapes everything except unreserved characters — letters, digits, and - _ . ! ~ * plus the apostrophe and both parentheses. Crucially it escapes &, =, ?, + and #, so a value containing any of them cannot break out of its parameter. This is the mode to use for essentially every value you put in a query string.

Whole URL keeps the structural characters intact — :, /, ?, &, =, # — because the input is already a complete URL and you want to escape only the unsafe parts within it, such as spaces and non-ASCII characters. Using this mode on a bare value is the mistake described next.

Path segment escapes slashes as well as query delimiters, so a value being placed as one segment of a path cannot add extra path levels. This is what you want for a filename or a slug built from user input.

Everything applies the strictest RFC 3986 rule and escapes every character outside the unreserved set, delimiters included. Use it when the output is an opaque token rather than a URL, or when a specification demands it.

The ampersand bug: why picking the wrong mode is not harmless

This deserves spelling out because the failure is silent and the mode choice looks cosmetic.

Suppose a user searches for salt & pepper. You build a URL by interpolating the raw term: ?q=salt & pepper. The server receives two parameters: q=salt and pepper with no value. The search returns results for salt, the user does not notice the missing half, and you get a bug report three weeks later that cannot be reproduced.

Now suppose you encode it with the Whole URL mode by mistake. That mode leaves & alone, so the result is salt%20%26%20pepper — actually correct here, because the ampersand was escaped by the mode that escapes everything except structure. The inverse mistake is more dangerous: encoding a whole URL with the Query value mode escapes its delimiters, so ?q=1&lang=en becomes a single parameter whose name contains the rest of the URL.

The rule that avoids both: decide what the string is before encoding it. If it is a value that will sit inside a query string, use Query value. If it is a complete URL being placed somewhere that needs one, use Whole URL. The two are not interchangeable, and the symptom of getting it wrong is a parameter count that is quietly off by one.

Plus signs, spaces and the two different standards

A space can be encoded two ways, and which one is correct depends on position — a distinction that causes a great deal of confusion.

In a URL path, a space must be %20. There is no alternative; a literal + in a path is a plus sign.

In a query string, %20 is always correct, and + is also accepted by the form-encoding convention application/x-www-form-urlencoded, which is what HTML forms submit by default. That convention is why you sometimes see ?q=hello+world and sometimes ?q=hello%20world. Both decode to the same string under that convention.

The ambiguity bites in the other direction. If a query value genuinely contains a plus sign — a phone number, a base64 fragment, a mathematical expression — and it is decoded with the form convention, the plus is read as a space and the value is silently altered. This is exactly why Base64 has a URL-safe variant: the standard alphabet uses +, which would be destroyed by a form decoder.

This encoder emits %20 for spaces, which is correct in both positions and unambiguous. That is the safer default, even though + would be marginally shorter. When decoding, the URL Decoder leaves plus handling as an explicit option rather than guessing, because guessing is what causes the corruption.

Non-Latin text, and how it reaches the wire

Percent-encoding operates on bytes, not characters. This matters for any text outside ASCII, because those characters occupy more than one byte in UTF-8.

A single Chinese character is three bytes in UTF-8, so encoding it produces three percent-escapes. The pair of characters for the word meaning tools encodes as %E5%B7%A5%E5%85%B7 — nine percent-escapes for two characters. Emoji are four bytes each, so one emoji becomes four escapes.

This is correct and expected, but it makes URLs containing non-Latin text visibly long. The important part is that the byte sequence is UTF-8 and not some legacy encoding, because a decoder assuming a different encoding will produce mojibake rather than an error. Modern practice is unambiguous here: everything is UTF-8, and this tool treats input as UTF-8 without offering an alternative.

Browsers do a certain amount of this automatically. Type Chinese characters into an address bar and the browser encodes them before sending. But nothing does it for you when you are constructing a URL in code, in a template, or by hand in a spreadsheet — which is where this tool earns its place.

Which mode for which job

Your input isModeResult
A search term or filter valueQuery valuesalt & pepper becomes salt%20%26%20pepper
An already-complete URL with a space in itWhole URLSpaces escape, delimiters stay as structure
A filename or slug going into a pathPath segmentSlashes escaped, so the value cannot add path levels
An email address used as a query valueQuery valueThe @ and + are escaped, so the address survives intact
A base64 payload going into a URLQuery valueSafer than encoding to standard base64, whose + becomes a space on decode
A whole URL going inside another URL parameterQuery valueAll delimiters escaped, which is what a redirect parameter needs
An opaque token with no URL structureEverythingStrictest escaping, delimiters included

Frequently asked questions

What is the difference between the encoding options?
The difference is which characters are treated as structure and left alone. Query value escapes everything except letters, digits and a few unreserved symbols, so ampersands, equals signs and question marks become safe data. Whole URL keeps the delimiters intact because the input is already a URL. Path segment also escapes slashes. Everything applies the strictest RFC 3986 rule.
Which one should I use for a search query value?
Query value. If you encode a value with the wrong option, an ampersand inside it will be read as a parameter separator and silently split your data into two parameters. That is the classic URL-encoding bug, and nothing throws an error when it happens.
Why does a space sometimes become + instead of %20?
In a query string, the form-encoding convention application/x-www-form-urlencoded allows + as shorthand for a space. Inside a path, only %20 is valid. This tool emits %20, which is correct in both positions and leaves no ambiguity for the decoder.
Does it double-encode already-encoded URLs?
It will, because it treats % as a literal character. If your input is already encoded, decode it first with the URL Decoder and then re-encode. Otherwise %20 becomes %2520 and you have added a layer rather than replaced one.
My URL contains Chinese characters — will this work?
Yes. Input is treated as UTF-8 and each multi-byte character is percent-encoded byte by byte, which is what the specification requires. Two Chinese characters become nine percent-escapes, because each occupies three bytes in UTF-8.
Should I encode the whole URL or just the values?
Just the values. Delimiters must stay unescaped or the URL stops being a URL, and only the parts that are data need escaping. The exception is a URL being placed inside another URL as a parameter, where the whole inner URL becomes a single value and every delimiter must be escaped.
Which characters are never encoded?
The unreserved set defined in RFC 3986: letters A to Z in both cases, digits 0 to 9, and the four symbols hyphen, period, underscore and tilde. These are safe in every part of a URL, so encoding them would only make the output longer without changing its meaning.
Does it handle email addresses and plus-addressing?
Yes, but the plus sign needs care. In Query value mode the + is escaped to %2B, which preserves it. If it were left raw and then decoded by a form-style decoder, the plus would become a space and the address would be altered. This is the same ambiguity that affects base64.
Is anything sent to a server?
No. Encoding happens entirely in the browser using built-in functions, with no network request. That makes it safe for internal URLs and for values containing tokens or identifiers.
Scroll to Top