DEV Community

Usman Farooqi
Usman Farooqi

Posted on Originally published at saveanyreel.com AI-assisted

How to URL Encode and Decode Text (With JavaScript Examples)

Quick answer: open the URL Encoder / Decoder, paste your text, and tap Encode or Decode. Spaces become %20, and characters like & or = become safe codes so a link does not break. Everything runs in your browser; nothing is uploaded.

Originally published on SaveAnyReel.

Why URLs need encoding

A web address can only use a limited set of characters safely. A space, a non-English letter, or a character that already means something in a URL (&, =, ?, #) must be written as a % code. That process is URL encoding (also called percent-encoding). Decoding turns those codes back into readable text.

Step by step (no code)

  1. Open the URL Encoder / Decoder.
  2. Paste the text (for example a search phrase or a full link).
  3. Tap Encode to get the percent-encoded form, or Decode to reverse it.
  4. Copy the result into your app, spreadsheet or address bar.

Common examples (tested)

Input Encoded (encodeURIComponent)
hello world hello%20world
a&b=c a%26b%3Dc
café caf%C3%A9

A full URL is different: you usually want to keep :// and / readable. In JavaScript that is encodeURI, which leaves those characters alone:

encodeURI("https://saveanyreel.com/search?q=hello world");
// → "https://saveanyreel.com/search?q=hello%20world"
Enter fullscreen mode Exit fullscreen mode
encodeURIComponent("hello world"); // "hello%20world"
decodeURIComponent("hello%20world"); // "hello world"
Enter fullscreen mode Exit fullscreen mode

These one-liners were run in Node before publishing this guide.

What this tool cannot do

  • It does not shorten links or create QR codes (use the QR Code Generator or WhatsApp link tool).
  • It does not fix a broken website; it only encodes or decodes text.
  • An invalid % sequence (for example %ZZ) cannot be decoded; the tool will say so.

Related

Try it: URL Encoder / Decoder →

Top comments (0)