URL Encoder & Decoder
Encode or decode URLs and URI components instantly in your browser. Switch between encodeURIComponent and encodeURI, compare their output side by side, and copy the result with one click. No data ever leaves your machine.
Try These Examples
Search URL— A URL with spaces, ampersands, and an equals sign in a query valueUnicode text— A string containing non-ASCII characters and emojiPre-encoded URL— An already-encoded URL ready to be decoded back to plain text
How It Works
URLs can only safely contain a limited set of ASCII characters. Any character outside that set must be percent-encoded — replaced with a % sign followed by the two-digit hexadecimal value of each byte in the character's UTF-8 representation. For example, a space becomes %20 and an ampersand becomes %26.
encodeURIComponent vs encodeURI
JavaScript provides two built-in functions for URL encoding, and choosing the right one matters:
encodeURIComponent(str)encodes everything except unreserved characters: letters, digits,-_.~. Use this when encoding a single value that will be placed inside a URL, such as a query parameter value or a path segment.encodeURI(str)encodes a complete URI but leaves characters with special URL meaning untouched:: / ? # [ ] @ ! $ & ' ( ) * + , ; =. Use this when you have a full URL that just needs its non-ASCII characters escaped.
Example
Given the input price = 100¤cy = EUR:
encodeURIComponent("price = 100¤cy = EUR")
// "price%20%3D%20100%26currency%20%3D%20EUR"
encodeURI("price = 100¤cy = EUR")
// "price%20=%20100¤cy%20=%20EUR"
Notice that encodeURI leaves = and & intact because those are valid URL delimiter characters. If you were embedding this string as a single query value, encodeURIComponent is the correct choice because it escapes those delimiters.
Decoding
The corresponding decode functions, decodeURIComponent(str) and decodeURI(str), reverse the encoding. If the input contains a malformed percent sequence (for example, %ZZ or a truncated %2), the decode function throws a URIError. This tool catches those errors and displays a clear message so you can locate and fix the issue.
Frequently Asked Questions
What is the difference between encodeURI and encodeURIComponent?
encodeURI encodes a full URI but preserves characters that have special meaning in a URL, such as : / ? # [ ] @ ! $ & ' ( ) * + , ; =. encodeURIComponent encodes everything except unreserved characters (letters, digits, - _ . ~), making it the right choice for encoding individual query parameter values or path segments.
When should I use encodeURIComponent?
Use encodeURIComponent whenever you are encoding a single component of a URI, such as a query parameter value, a path segment, or a fragment. For example, if a user's search query contains characters like & or =, encodeURIComponent ensures those characters are escaped so they are not misinterpreted as URL delimiters.
What is percent-encoding?
Percent-encoding (also called URL encoding) replaces unsafe or reserved characters with a percent sign (%) followed by two hexadecimal digits representing the character's UTF-8 byte value. For example, a space becomes %20, an ampersand becomes %26, and the euro sign (€) becomes %E2%82%AC.
Is my data safe when I use this tool?
Yes. This tool runs entirely in your browser using JavaScript's built-in encoding functions. No data is sent to any server. You can verify this by checking the Network tab in your browser's developer tools while using the tool.