plain/devtools home

URL encode and decode

URL encoding replaces unsafe characters with % and two hex digits of their UTF-8 bytes: a space is %20, & is %26. Encode each value you put into a URL, and decode when you read one back.

Last reviewed 2026-11-04.

url-encodersamplesCtrl↵ run · s sample · c copy

never leaves your browser

Worked examples

InputEncoded
hello world & morehello%20world%20%26%20more
a/b?c=da%2Fb%3Fc%3Dd
café ☕caf%C3%A9%20%E2%98%95
100% sure+1100%25%20sure%2B1

encodeURI or encodeURIComponent

  • encodeURIComponent encodes everything except letters, digits and - _ . ! ~ * ' ( ). Use it for a single query value or path segment.
  • encodeURI leaves : / ? # & = alone so a whole URL stays usable. encodeURI("a/b?c=d") is unchanged; encodeURIComponent gives a%2Fb%3Fc%3Dd.
  • Non-ASCII text is encoded as UTF-8 bytes: é is %C3%A9.

Decoding

Switch the tool to Decode. decodeURIComponent("a%20b") gives a b. In form-encoded query strings a + also means a space, but decodeURIComponent does not convert it: decodeURIComponent("a+b") stays a+b. A stray % that is not followed by two hex digits throws a URIError.

Running this on a server

Encoding bugs usually show up in a server that receives the URL. The hosting guide compares small hosts.

Frequently asked questions

Is a space %20 or +?

%20 everywhere. + means a space only in application/x-www-form-urlencoded form data and query strings.

Should I encode the whole URL?

No. Encode each value, then join. Encoding the whole URL also encodes the slashes and colon.

Why double encoding?

Encoding an already encoded string turns % into %25. Encode once, at the point you build the URL.

Sources

Related

esc
↑↓ move↵ open? all shortcuts

Keyboard shortcuts

Cmd or Ctrl shortcuts always work.
Everywhere
Everywhere
Open the command palette
CtrlK
Open the palette (outside a text field)
/
Show these shortcuts
?
Toggle light and dark theme
t
Go home
gh
Go to all tools
gt
On a tool page
On a tool page
Run the main action
Ctrl↵
Copy the output
c
Load the next sample
s
Focus the input
i
Leave a text field
Esc
Previous or next tool
[]
In the palette
In the palette
Move the selection
↑↓
Open the selected item
↵
Close
Esc