URL Encoder & Decoder
Encode or decode URLs with encodeURIComponent/encodeURI modes, and split query strings into readable parameters. Invalid percent sequences fail loudly. Runs locally.
A URL can only contain a limited character set, so spaces, ampersands, equals signs, question marks, hashes and non-ASCII text all have to become percent-encoded — a percent sign followed by hexadecimal bytes — to travel safely in an address. Two modes are offered: component (encodeURIComponent) escapes even the structural characters and suits a parameter value, while uri (encodeURI) preserves them and suits a whole address.
Mixing the two modes is a common source of garbled output: using uri mode on a parameter value leaves the ampersands and equals signs in place and cuts the query structure apart. Decoding refuses to guess as well — an incomplete percent sequence is reported as an error, since such input is not a valid sequence of UTF-8 bytes, and silently emitting a garbled result would be far harder to debug.
Did this tool solve your problem?
Submitting sends the tool name, your input and the current result to the server. Please do not include ID numbers, phone numbers or other private data.
AI assistant It answers using your current input and result
Asking again sends your current input and result to the server once more. Please do not include private data.
How to use
- Choose the mode: component for a value, uri for a whole address.
- Paste the text and encode, or the encoded string and decode.
- Check the query string splits into parameters where expected.
- An incomplete percent sequence is an error, not something to guess at.
How it works
Component vs. URI mode
Component mode (encodeURIComponent) escapes everything except alphanumerics and - _ . ! ~ * ' ( ) — including : / ? = & # — for encoding a single parameter value; URI mode (encodeURI) keeps URL structural characters and escapes only non-ASCII and spaces, for encoding a whole address.
Decoding errors and why
Decoding calls the matching decode function for the chosen mode. Incomplete percent sequences (like %E4%BD) or bare percent signs (like 100%) error out directly — they're not valid UTF-8, and forcing a decode yields only mojibake.
Query-string auto-parsing
In decode mode, input shaped like a query string (containing = or &) splits automatically on & and = into key-value pairs, with + read as space (form convention) and repeated keys all kept in order.
Code example
JavaScript Encoding and decoding
// A parameter value (escapes : / ? = &)
encodeURIComponent("a=1&b=café") // a%3D1%26b%3Dcaf%C3%A9
// A whole URL (keeps : / ? = &)
encodeURI("https://a.com/p?x=café") // https://a.com/p?x=caf%C3%A9
// Decoding
decodeURIComponent("%C3%A9") // é
PHP The two encodings in PHP
<?php
echo urlencode("a=1 b"); // a%3D1+b (+ means a space)
echo rawurlencode("a=1 b"); // a%3D1%20b (%20 means a space)
var_dump(urldecode("a%3D1+b")); // string(5) "a=1 b"
FAQ
encodeURI vs. encodeURIComponent — what's the difference?
encodeURI processes a whole URL, preserving : / ? # & = structure; encodeURIComponent processes a parameter value, escaping those structure characters too so an & inside the value can't be read as a separator. Always use the latter for parameter values, or values containing & or = will corrupt the URL.
Why does a space become %20 or +?
%20 is the URL standard's space; + is the HTML form (application/x-www-form-urlencoded) shorthand — same meaning, different contexts. This tool encodes to %20 and decodes + as space too, so strings from either source restore correctly.
Which characters stay unescaped?
Component mode keeps only A-Z a-z 0-9 and - _ . ! ~ * ' ( ); URI mode additionally preserves ; / ? : @ & = + $ , #. Chinese, emoji, spaces and quotes always become %XX sequences in either mode.
Decoding says the percent sequence is incomplete — now what?
The input isn't valid encoded text: typically % followed by fewer than two hex digits (like 100%), or a truncated UTF-8 multi-byte sequence (%E4%BD holding two of a Chinese character's three bytes). Check whether the string was cut short, or confirm it really is encoded content before decoding.
How does Chinese travel inside a URL?
The browser first encodes it as UTF-8 bytes (中 is E4 B8 AD), then writes each byte as %XX — so 中 becomes %E4%B8%AD. Decoding reverses the steps, which is why truncated bytes break decoding.
Are the results uploaded?
No. Encoding, decoding and parameter splitting all use native browser functions — nothing crosses a server and it works offline. URLs containing tokens and signatures are safe to process.
When do I encode vs. decode?
Encode before putting Chinese or special characters into a URL or parameter; decode when a log, URL or capture shows %XX strings you want readable. Quick tell: strings full of %E4/%E5/%E6 three-byte starts are almost always encoded Chinese.