Skip to content
cosmodev ~/tools/url-encode

URL-koding / dekoding

Encoders & Crypto

Prosentkod eller dekod URL-er og spørringsparametre. Velg komponentmodus (encodeURIComponent) eller full-URI-modus (encodeURI). 100 % på klientsiden.

Utdata
Skriv eller lim inn tekst for å se den kodet.

(Dokumentasjon på engelsk)

What it does

Converts text to percent-encoded form and back. Two choices control the result: a direction (Encode or Decode) and a scope (Component or Full URI). Component mode applies encodeURIComponent, which escapes every reserved character and is right for query values. Full URI mode applies encodeURI, which keeps ; / ? : @ & = + $ , # intact so a whole URL stays a URL. Malformed input, such as a stray % on decode, shows a clear error instead of a wrong answer.

How to use it

  1. Pick a direction: Encode or Decode.
  2. Pick a scope: Component for a single query value, Full URI for a whole URL.
  3. Type or paste into the Input box. The Output box updates as you type.
  4. Copy the output, or copy a share link that encodes the direction, the scope, and your text.

The Swap button flips direction and carries the current output into the input. Encode something, tap Swap, and the tool decodes it back in one click - no retyping.

Examples

Input Setting Output
hello world Encode, Component hello%20world
https://dev.cosmolabs.org/tools/url-encode Encode, Full URI unchanged - every character is URL-safe
https://example.com/search?q=hello world&page=2 Encode, Full URI https://example.com/search?q=hello%20world&page=2
path=/users/42 Encode, Component path%3D%2Fusers%2F42
hello%20world Decode, Component hello world

How percent-encoding works

A URI is ASCII. That rule survives from the earliest URL specifications: a URL travels as ASCII bytes, and anything else must ride inside an escape. The escape is always three characters: % plus two hex digits naming the byte. A space is byte 0x20, so it travels as %20. An é is two bytes in UTF-8 (0xC3 0xA9), so it travels as %C3%A9.

JavaScript ships two encoders, and the scope switch picks between them:

encodeURIComponent (Component) encodeURI (Full URI)
Escapes everything except A-Z a-z 0-9 - _ . ! ~ * ' ( ) same, but also keeps ; / ? : @ & = + $ , #
Built for one query value one whole URL
a/b?c=d a%2Fb%3Fc%3Dd a/b?c=d

The reserved characters are the URL’s own punctuation, and that is why the two functions exist. A query value like path=/users/42 must escape its slashes, or the receiver cannot tell data from structure: path=%2Fusers%2F42. A whole URL must keep them, or https:// collapses into https%3A%2F%2F. Rule of thumb: encode with the narrowest scope that fits the piece you hold, and you never escape the structure you actually need.

Decoding runs the reverse: each %XX becomes the byte it names, and the bytes reassemble as UTF-8 text. A % not followed by two hex digits is malformed, and the tool reports it rather than guessing.

Good to know

  • Decode once, not twice. A value that legitimately contains %20 decodes to a space; decoding that result again turns any stray % into an error.
  • The share link carries mode, scope, and text, so opening it restores your exact conversion.
  • Private: all encoding runs locally in your browser. Nothing is sent anywhere.
  • Related tools: URL Inspector, HTML Entity Encoder, Base64Base64An encoding representing binary data as 64 safe ASCII characters, so it survives transport through text-only channels. It encodes — it does not encrypt. Encode / Decode.
Kildekode14 språk

100 % på klientsiden · dataene dine forlater aldri nettleseren. Nyttig? Del det med en kollega.