Home / Developer tools / URL encoder

URL Encoder

Paste text, a parameter value or a link and get it back percent-encoded, ready for a URL. Choose the encoding method, the hex case and whether to encode line by line.

Try:

Everything runs in your browser. Your text is not sent to our server.

What a URL encoder does

A URL can only carry a small set of safe characters: letters, digits and - . _ ~. Anything else, such as a space, an accent, an emoji or a character that has a special meaning in a URL (&, =, ?, #, /), must be written as a percent code: a % followed by two hex digits for each byte of its UTF-8 form. This is called URL encoding or percent-encoding, and it is defined in RFC 3986. A URL encoder turns your text into that form so that it travels safely inside a link, a query string, a form post or an API call.

Example

Text with spaces, an accent and reserved characters:

café & tea = 5€ / cup

Encoded as a single value (component method):

caf%C3%A9%20%26%20tea%20%3D%205%E2%82%AC%20%2F%20cup

The letter é is two bytes in UTF-8 (C3 A9), and the euro sign is three (E2 82 AC), so they become two and three percent codes.

Which method should I choose?

MethodUse it forSpace becomesKeeps
ComponentOne value: a query parameter, a path segment, a fragment. The safe default.%20A-Z a-z 0-9 - _ . ! ~ * ' ( )
Full URLA complete link where : / ? # & = must keep working.%20Component set plus ; , / ? : @ & = + $ #
Form (+)HTML form bodies and application/x-www-form-urlencoded.+A-Z a-z 0-9 * - . _
RFC 3986 strictSignatures (OAuth, AWS) that need exact, predictable output.%20A-Z a-z 0-9 - . _ ~
Every characterObfuscation or tests: even letters become %XX.%20Nothing

When you are not sure, use Component for a value and Full URL only for a whole link. Not sure which is right? The encodeURI vs encodeURIComponent comparison shows all of them side by side for your own text.

Options

  • Hex case. %C3%A9 (uppercase, recommended by RFC 3986) or %c3%a9 (lowercase). Both mean the same.
  • Do not double-encode existing %XX. Leaves sequences that are already encoded alone, so caf%C3%A9 does not become caf%25C3%25A9. Use it only when the input is a mix of raw and encoded text.
  • Encode line by line. Each line is encoded on its own and the line breaks are kept, handy for lists of values or keywords.

Encode in code

// JavaScript
encodeURIComponent('café & tea');        // "caf%C3%A9%20%26%20tea"
new URLSearchParams({q: 'café & tea'}); // "q=caf%C3%A9+%26+tea"

// PHP
rawurlencode('café & tea');   // caf%C3%A9%20%26%20tea  (RFC 3986)
urlencode('café & tea');      // caf%C3%A9+%26+tea      (form style)

# Python
from urllib.parse import quote, quote_plus
quote('café & tea', safe='')   # 'caf%C3%A9%20%26%20tea'
quote_plus('café & tea')       # 'caf%C3%A9+%26+tea'

Common mistakes

  • Encoding a whole URL with the component method. https:// turns into https%3A%2F%2F and the link stops working. Encode each value, then put the URL together.
  • Encoding twice. A % becomes %25, so %20 turns into %2520. Encode raw text once, and only once.
  • Using + outside forms. + means a space only in the query string of form data. In a path, a space must be %20.

Privacy

The encoding runs in your browser with plain JavaScript. Your text is not uploaded, stored or logged.

Next steps: the URL decoder reverses the result, the percent-encoding tool shows every byte, and the query string builder assembles whole parameter lists. For the rules behind all this, read the URL encoding guide. Related: HTML encode for web page text.

Frequently asked questions

How do I URL encode a string?

Paste the text into the box. It is encoded at once. Choose Component for a single value or Full URL for a whole link, then press Copy.

What is the difference between URL encoding and percent-encoding?

They are the same thing. Each unsafe byte is written as a percent sign and two hex digits, for example a space as %20.

Why does my space become %20 and not +?

RFC 3986 uses %20 everywhere. The + sign is a convention of HTML form data. Choose the Form method if you need +.

Does it work with Unicode, emoji and Arabic?

Yes. Text is converted to UTF-8 first, and every byte is encoded, so any language and any emoji works.

Is my text uploaded to a server?

No. Everything runs in your browser, and nothing you paste leaves your device.