Encode and decode URLs and query parameters with full UTF-8 support. Pick the right mode for what you're
encoding β encodeURI for whole URLs, encodeURIComponent for individual values.
All work happens in your browser.
| Character | encodeURI |
encodeURIComponent |
form-encoded |
|---|---|---|---|
| space | %20 | %20 | + |
| / | / (kept) | %2F | %2F |
| ? | ? (kept) | %3F | %3F |
| # | # (kept) | %23 | %23 |
| & | & (kept) | %26 | %26 |
| = | = (kept) | %3D | %3D |
Use encodeURI for a whole URL you trust, encodeURIComponent for any single
path segment or query value, and form-encoded only for application/x-www-form-urlencoded bodies.
When should I use which encoder?
Use encodeURIComponent for individual query values or path segments β
?q=encodeURIComponent("a&b") ensures the & doesn't split the query.
Use encodeURI for an entire URL string that's already structured correctly.
Use form-encoded only when building an HTML form body.
Why do I get "URI malformed" when decoding?
A % sign that isn't followed by two valid hex digits triggers this. Common causes: a literal
% in the string that wasn't encoded as %25, or a truncated sequence at the end.
Does this handle UTF-8 and emoji?
Yes. The browser's encodeURIComponent and decodeURIComponent deal in UTF-8
byte sequences, so multi-byte characters round-trip correctly.
Is my data uploaded?
No. Everything runs in your browser. No bytes leave the page.