Result
Result
| 1 |
About the URL Encode / Decode Tool
About the URL Encode / Decode Tool
Overview
A URL full of %XX sequences is unreadable at a glance, and remembering whether encodeURI or encodeURIComponent is the right call for a given string trips up most developers at some point. This tool runs both directions — encode a raw string into percent-encoded form, or decode an encoded one back to plain text — using the exact same JavaScript methods you'd call in code, so the result matches what your app will actually produce.
How to Use
- 1Type or paste the text into String to convert — this works whether it's already encoded or still plain text.
- 2Set Mode to Encode or Decode depending on which direction you need.
- 3Turning on Convert all URL symbols (e.g. / and ?) as well switches to encodeURIComponent behavior, encoding every reserved character. Leave it off to use encodeURI behavior, which leaves URL structure characters like / and ? untouched.
- 4Click Convert to see the result, or Clear to start over.
Specifications & Glossary
- encodeURI: Does not encode characters that are valid in a URL (scheme http://, path separator /, query characters ?, =, &, etc.). Use when passing the entire URL.
- encodeURIComponent: Encodes all characters except A-Z a-z 0-9 - _ . ! ~ * ' ( ). Use when passing a part of a URL, such as a query parameter value.
- Percent encoding (RFC 3986): The mechanism behind the %XX notation. Each character is first encoded as UTF-8 bytes, then each byte is written as %XX in hex — a multi-byte character like "あ" expands to multiple %XX groups, e.g. %E3%81%82.
- Decoding: Supports decodeURI and decodeURIComponent to restore encoded strings back to their original text.
- Difference between encodeURI and encodeURIComponent: encodeURI does not encode URL structural characters such as :, /, ?, and #, while encodeURIComponent encodes all of them.
- Double encoding: Encoding a string that's already encoded turns the
%character itself into%25, breaking a clean round trip back to the original text. Check whether the input already contains%XXsequences before converting.
Use Cases
- Encoding non-ASCII text or special characters before putting them into an API request's query parameters.
- Converting form field values into a URL-safe format before building a query string by hand.
- Making sense of a long percent-encoded URL from a browser address bar, server log, or bug report.
- Settling the classic "+ vs %20" confusion: form submissions (application/x-www-form-urlencoded) traditionally encode a space as +, while encodeURIComponent and a URL's path always use %20 — mixing the two conventions is a common source of subtly broken query strings.
- Converting a URL with a Japanese domain or path into a form that's safe to share or paste elsewhere.
FAQ
- Should I use encodeURIComponent or encodeURI?
- Use encodeURIComponent when you're encoding a fragment of a URL — a query parameter value, a single path segment. Use encodeURI when you already have a complete, well-formed URL and want to encode it as a whole while keeping structural characters like
/and?intact. - How does encoding handle URLs containing Japanese text?
- Japanese and other multi-byte characters are first converted to their UTF-8 byte sequence, and each byte is then written as
%XX. The character "あ" is 3 bytes in UTF-8, so it expands into the three-part sequence%E3%81%82. - What happens if I accidentally encode a string twice?
- Encoding an already-encoded string a second time turns the literal
%character into%25, and decoding it once no longer gets you back to the original string. Check whether your input is already encoded before running it through the tool again. - Which characters in a query parameter actually need encoding?
- Spaces and multi-byte characters like Japanese are obvious candidates, but reserved characters that carry structural meaning —
&,=,?, and#— need encoding too if a value might contain them. Enabling Convert all URL symbols as well encodes all of these along with everything else. - Does this tool encode spaces as "+" or as "%20"?
- This tool follows JavaScript's built-in encodeURI/encodeURIComponent behavior, which always represents a space as
%20. The "+" convention for spaces belongs toapplication/x-www-form-urlencodedform submissions, a separate encoding scheme that this tool doesn't produce. - In what situations does decoding fail?
- Decoding fails when a "%" isn't followed by exactly two hex digits (for example, a string that ends abruptly with "%2"), or when the decoded bytes don't form valid UTF-8. Double-check the string before it was encoded and try again.