How to encode a URL or query string?
Paste the text you want to encode and choose an encoding mode:
- Enter or paste your text into the input field. For example, a search query like 'hello world & more' or a full URL with special characters.
- Choose a mode: 'Component' uses encodeURIComponent (encodes every reserved character, best for query parameter values); 'Entire URL' uses encodeURI (keeps : / ? & = etc. intact, best for whole URLs).
- Optionally tick '+ for spaces' to replace %20 with + (application/x-www-form-urlencoded style used by HTML forms and many APIs).
- Click 'Encode'. The result appears instantly in the output area. Copy it, swap input/output, or clear to start over. Everything runs locally in your browser.
How to decode an encoded URL?
Decoding is the reverse operation:
- Paste the percent-encoded string (e.g. https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Dhello%2520world) into the input.
- Click 'Decode'. In Component mode, '+' characters are treated as spaces, matching how query strings are sent by browsers.
- Use 'Swap' to move the decoded result back to the input, then encode it again to verify round-tripping.
What is percent-encoding?
Percent-encoding (also called URL encoding) is the mechanism for representing arbitrary data in a URL. Reserved characters — : / ? # [ ] @ ! $ & ' ( ) * + , ; = — plus spaces and non-ASCII letters — are replaced by a '%' followed by the two hex digits of their UTF-8 byte. For example, a space becomes %20, 'đ' becomes %C4%91, and '?' becomes %3F. This guarantees the URL is unambiguous: encoded characters can never be misinterpreted as URL syntax. The name comes from ASCII code 37 (%), which is used as the escape marker.
- Space → %20 (or + in form encoding)
- ? → %3F, & → %26, = → %3D, # → %23
- Non-ASCII (UTF-8) → e.g. 'ế' → %E1%BA%BF
encodeURIComponent vs encodeURI
JavaScript offers two encoding functions with different purposes. encodeURIComponent encodes every character except A-Z a-z 0-9 - _ . ! ~ * ' ( ). It is the correct choice for building query string values, since it escapes characters that have syntactic meaning in a URL such as & = ? and #. encodeURI leaves the reserved set ; / ? : @ & = + $ , # untouched, which is exactly what you want when encoding a complete URL whose structure you want to preserve. A common bug is using encodeURI for a parameter value containing '&' or '#', or using encodeURIComponent on a full URL — both corrupt the result.
Why '+' equals space in query strings
In the application/x-www-form-urlencoded format (used by HTML forms and many APIs), a space is encoded as '+', not '%20'. Percent-encoding of the same query string normally produces %20. When decoding, a robust tool therefore converts '+' back to a space first. This asymmetry trips up developers: a value that literally contains a '+' must be percent-encoded as %2B to survive the trip through a form, otherwise it arrives as a space. This tool lets you toggle the '+' behavior on encode and always normalizes '+' when decoding in Component mode.
Frequently Asked Questions (FAQs)
What is the difference between URL encoding and HTML encoding?
URL encoding (percent-encoding) transforms characters so they are safe inside a URL: spaces become %20, and reserved characters like ? and & become %3F and %26. HTML encoding transforms characters so they render safely in HTML documents: < becomes <, > becomes >, & becomes &. They use different escape schemes and are not interchangeable — encoding a URL with HTML entities produces a broken link, and vice versa.
Should I encode the whole URL or only the parameters?
In most cases you should encode only the dynamic parts: the parameter names, values, and any dynamic path segments, using encodeURIComponent. The URL structure (https://, the domain, slashes, ? and = separators) should stay as-is. If you run encodeURIComponent over a full URL, you get https%3A%2F%2Fexample.com — which browsers will not navigate to as a normal link, because the scheme and slashes have been escaped.
Does URL encoding work with Vietnamese text and Unicode?
Yes. Modern URLs are encoded as UTF-8 bytes, so Vietnamese diacritics like ế, ơ, ư and characters like đ are converted to their UTF-8 percent-encoded form (e.g. 'đ' becomes %C4%91). The encoded string is pure ASCII and safe to embed in any URL or query string. The server then decodes it back to the original text. This also works for emoji and any other Unicode characters.
Why did my decode fail with an error?
Decoding fails when the input is not valid percent-encoding — for example, a '%' not followed by two hex digits (%G1), or an incomplete sequence at the end of the string. It can also fail if the string contains a '%' that was written by a different encoding scheme. Normal text that was never encoded does not need decoding: run Encode on plain text, and only Decode strings you know were percent-encoded.
Is the data sent to a server when I use this tool?
No. All encoding and decoding happens locally in your browser using built-in JavaScript functions (encodeURI, encodeURIComponent, decodeURI, decodeURIComponent). Nothing you type is transmitted over the network — you can even use this tool offline once the page is loaded.