Skip to content
cliplimeClipLime

Encode, decode and parse URLs

Percent-encode text, decode it again, and read any query string as a table.

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
Encodes and decodes percent-encoded text, and splits any URL or query string into its parts and a table of keys and values.
Three styles
encodeURIComponent for one value, encodeURI for a whole URL, and form style that writes spaces as +.
Decoding
Never stops on a bad escape: invalid sequences stay as typed and are reported. It also spots text that was encoded twice.
Parsing
Scheme, host, port, path, query and fragment, plus every query parameter decoded, with repeated keys flagged.
Unicode
Characters outside ASCII are written as UTF-8 bytes, so é becomes %C3%A9.
Privacy
Runs in your browser. A URL you paste is only split apart as text. It is never opened or requested.

How to do it

  1. 1

    Pick a view

    Choose Encode, Decode or Parse a URL at the top of the tool.

  2. 2

    Paste your text

    Paste a value, a URL or a query string. The result updates as you type.

  3. 3

    Choose the style

    When encoding, pick a single value, a whole URL or form style. Each choice says which characters it leaves alone.

  4. 4

    Copy the result

    Copy the encoded or decoded text, or copy the parsed parameters as JSON.

encodeURIComponent versus encodeURI

JavaScript has two built-in encoders, and choosing the wrong one is the most common URL bug. Take the text https://example.com/a b?x=1&y=2:

  • encodeURI gives https://example.com/a%20b?x=1&y=2. It keeps the characters that give a URL its structure (: / ? # & = and a few more) and only fixes what is not allowed, such as the space. Use it on a complete address.
  • encodeURIComponent gives https%3A%2F%2Fexample.com%2Fa%20b%3Fx%3D1%26y%3D2. It encodes everything that could be mistaken for structure. Use it on one piece of data, such as a query value or a path segment.

The rule of thumb: if the text is going into a URL as data, use the single value style. If the text is the URL, use the whole URL style. Encoding a complete URL with the single value style breaks it, and putting a raw URL inside another URL's query breaks that URL.

How percent-encoding works

A URL may only contain a small set of characters. Anything else is written as a percent sign followed by the two hex digits of each byte. A space is the byte 20, so it becomes %20. Characters outside ASCII are first turned into UTF-8 bytes, so é (two bytes) becomes %C3%A9, and an emoji such as 👋 (four bytes) becomes %F0%9F%91%8B.

Letters, digits and the four characters - _ . ~ never need encoding. Characters such as : / ? # [ ] @ ! $ & ' ( ) * + , ; = have a job in URLs, so they must be encoded when they appear as data rather than as structure.

Spaces: %20 or +

Both mean a space, but in different places. %20 works everywhere in a URL. The + form comes from HTML forms (application/x-www-form-urlencoded) and is only valid in a query string. In a path, + is a real plus sign.

To send a real plus sign in a query value, write %2B. A phone number such as +1 555 becomes %2B1%20555, or %2B1+555 in form style.

Reading a query string

The Parse a URL view splits an address into scheme, host, port, path, query and fragment, then lists each parameter with its decoded key and value. The text as typed is shown underneath when it differs, so you can see exactly what the server receives.

Keys that appear more than once are flagged. Servers and frameworks disagree about them: some keep the first value, some the last and some collect a list. The JSON copy shows them as lists.

Questions people ask

What is the difference between encodeURI and encodeURIComponent?

encodeURI is for a whole address and leaves : / ? # & = + $ , ; and @ alone. encodeURIComponent is for one piece of data and encodes all of those. Both encode spaces, quotation marks, <, >, % and non-ASCII characters.

Why did my text turn into %2520?

It was encoded twice. The first pass turned a space into %20, and the second turned the % into %25. Decode it twice to get the original. The Decode view points this out when it sees leftover escapes.

Should I use %20 or + for a space?

Use %20 unless you are building form data. It is valid everywhere in a URL, while + only means a space in a query string.

Which characters never need encoding?

Letters, digits and the four characters - _ . ~. These are the unreserved characters in RFC 3986.

Does this tool open or request the URL I paste?

No. The text is only split and decoded in your browser. Nothing is fetched, and nothing is sent anywhere.

Does it work with non-English text?

Yes. Any character is converted to UTF-8 bytes and written as %XX for each byte, and decoding turns those bytes back into characters.