TirupatiTECHNOLOGIES
Developer Tools

URL Encoder & Decoder

URLs can only safely contain certain characters — spaces, Hindi text and symbols like <code>&amp;</code> must be percent-encoded (<code>%20</code>, <code>%26</code>…) before they travel over HTTP. This tool encodes and decodes URLs instantly, and offers both <code>encodeURI</code> (for whole URLs) and <code>encodeURIComponent</code> (for values inside query parameters), with the difference explained right in the tool.

Mode

Encode (URI) uses encodeURI — it leaves URL structure characters like : / ? # & untouched, so use it on full URLs. Encode component uses encodeURIComponent — it encodes those too, so use it when a value goes inside a query parameter.

How it works

Percent-encoding replaces each unsafe byte with % followed by two hex digits:

  1. Encode (URI) — encodeURI(): encodes the text as UTF-8, then percent-encodes everything except URL structure characters (A–Z a–z 0–9 ; , / ? : @ & = + $ - _ . ! ~ * ' ( ) #). Use on complete URLs.
  2. Encode component — encodeURIComponent(): encodes a stricter set, including / ? : @ & = + $ , #. Use on a single value you're placing inside a query string, so its special characters can't break the URL's structure.
  3. Decode — decodeURIComponent() reverses the process, turning %XX sequences back into characters. Malformed sequences (a % not followed by two hex digits) produce a clear error instead of silent garbage.

Worked example

Take https://example.com/search?q=chai & coffee. Encode (URI) gives https://example.com/search?q=chai%20&%20coffee — the structure survives. Encode component on just chai & coffee gives chai%20%26%20coffee — the & is encoded so it can't split your query string in two.

Understanding your results

Encoded output is safe to use in links, redirects and API calls. Decoded output restores the human-readable form. If decoding fails with an "invalid percent-encoding" error, the input has a stray % — often from a URL that was already decoded once (double-decoding is a classic bug).

Frequently asked questions

encodeURI is for whole URLs — it leaves : / ? # & = and friends alone so the URL keeps working. encodeURIComponent is for a single value inside a URL — it encodes those characters too, so a & inside your value doesn't get mistaken for a parameter separator.

Content last reviewed on 2026-10-06.