Skip to content
cliplimeClipLime

URL encode

Make any text safe to put in a URL, and see all three styles side by side.

Your text stays in your browser and no URL is requested

0 characters, 0 lines

Options

encodeURIComponent leaves these alone. Turn this on to follow RFC 3986 strictly, which some APIs and signature schemes require.

Encodes line by line and keeps the line breaks, handy for a list of values.

At a glance

What it does
Percent-encodes text so it is safe to put in a URL, as you type.
Styles
A single value (encodeURIComponent), a whole URL (encodeURI), or form style with + for spaces.
Strict option
Also encodes ! ' ( ) *, as RFC 3986 requires and some signature schemes expect.
Compare
Shows the same text in all three styles, so you can see which one you need.
Lists
Encode a list of values at once, one per line.
Privacy
Your text stays in your browser.

How to do it

  1. 1

    Paste the text

    Type or paste a value, a path piece or a whole URL.

  2. 2

    Choose a style

    Pick A single value for query values and path segments, A whole URL for a complete address, or Form style for form data.

  3. 3

    Check the comparison

    The panel below the result shows all three styles, so you can see how they differ for your text.

  4. 4

    Copy the result

    Press Copy and paste it into your URL, code or request.

Which characters each style leaves alone

  • A single value keeps letters, digits and - _ . ! ~ * ' ( ). Everything else, including / ? # & = + : and spaces, is encoded.
  • A whole URL keeps all of those plus ; , / ? : @ & = + $ #, so the structure of the address survives.
  • Form style keeps letters, digits and - _ . *. A space becomes +, and ~ ! ' ( ) are encoded. This is what an HTML form or URLSearchParams produces.

Everything outside ASCII is converted to UTF-8 first. A lone half of an emoji, which cannot be written in UTF-8, is replaced and you are warned.

Putting one URL inside another

Login and redirect flows often carry a URL as a parameter, such as ?next=.... If that value is not encoded, its own ? and & are read as part of the outer URL. With https://example.org/a?x=1&y=2 as the value, the raw version would hand the server next=https://example.org/a?x=1 and a separate parameter y=2.

Encoded with the single value style, it becomes https%3A%2F%2Fexample.org%2Fa%3Fx%3D1%26y%3D2, and the server receives the whole address as one value.

Common mistakes

  • Encoding a whole URL as a single value, which turns https:// into https%3A%2F%2F and stops it working as a link.
  • Encoding twice, which turns %20 into %2520. Encode raw text exactly once.
  • Leaving + and & raw in a value. In a query string + is read as a space and & starts a new parameter. Encode values before joining them with &.

In code, the equivalents are encodeURIComponent(value) in JavaScript, urllib.parse.quote(value, safe="") in Python and rawurlencode($value) in PHP. In Python and PHP, quote_plus and urlencode give the form style with + for spaces.

Questions people ask

Why is my slash encoded as %2F?

You are using the single value style, which encodes / because inside a value it is just data. If you are encoding a whole address and want slashes kept, switch to A whole URL.

Does encodeURIComponent encode every special character?

Not quite. It leaves ! ' ( ) * and ~ alone. If an API or signature scheme needs these encoded too, turn on Also encode ! ' ( ) *.

How do I encode a space, %20 or +?

Use %20 in paths and everywhere else. Use + only in form-style query strings. The Form style option writes +.

How are non-English characters encoded?

They are converted to UTF-8 bytes and each byte is written as % and two hex digits. é becomes %C3%A9, and 你 becomes %E4%BD%A0.

Is my text uploaded?

No. Encoding happens in your browser and nothing is sent anywhere.