Eskillsfy

Home / Blog / Encode and decode

Encode and decode · 23 Nov 2026

URL Encode & Decode: how it works and how to build one

Percent-encode text, decode URLs and split a URL into parts. This guide explains what happens behind the button and shows the code, so you can build your own.

What it does

Encode a value for a query string, decode a messy tracking link, or paste a full URL to see its protocol, host, path and every query parameter in a table.

When to use it

  • Building query strings by hand
  • Reading tracking links
  • Debugging redirects

How to use it

  1. Choose Encode, Decode or Parse URL.
  2. Paste your text or link.
  3. Copy the result.

Try it free in your browser, nothing is uploaded: https://eskillsfy.com/tools/url-encoder

How it works

URLs can only contain a small set of characters. Everything else is written as % followed by two hex digits per UTF-8 byte. encodeURIComponent encodes everything except letters, digits and – _ . ! ~ * ‘ ( ), which is right for a single value.

encodeURI leaves : / ? & = # alone, so it suits a full URL. Parsing uses the built-in URL class.

Build it yourself

Here is the core of the tool. It has no dependencies unless noted, so you can paste it into any TypeScript or JavaScript project.

url.ts (ts)

encodeURIComponent("Bengaluru & Mysuru");   // "Bengaluru%20%26%20Mysuru"
decodeURIComponent("caf%C3%A9");            // "café"

export function parseUrl(href: string) {
  const u = new URL(href);
  return {
    protocol: u.protocol, host: u.hostname, port: u.port, path: u.pathname, hash: u.hash,
    params: [...u.searchParams.entries()],
  };
}

Make it production-ready

  • Treat + as a space when decoding form-encoded data.
  • Show each query parameter in a table with copy buttons.

Questions

encodeURI or encodeURIComponent?

Encode uses encodeURIComponent, which is what you want for a single query value. Use Encode full URL to keep : / ? & intact.

Try the URL Encode & Decode

Free, runs in your browser, nothing is uploaded.

Open it
Keep reading

More in Encode and decode

All posts