URL Encode
Encode text for safe URL transmission or decode URL-encoded strings. Shows character mappings for special characters. Free, instant, and accurate.
The formula
URL Encoding = % + hex code (e.g., space → %20)
- input
- Input Text
- encoded
- Encoded Output
How URL Encode Works
URL Encoding = % + hex code (e.g., space → %20)
URL encoding (percent-encoding) converts characters into a format that can be safely transmitted in URLs by replacing unsafe characters with % followed by their two-digit hex code. Every character has an ASCII code, and percent-encoding simply writes that code in hexadecimal preceded by a percent sign. For example, the space character has ASCII code 32 decimal, which is 20 in hex, so it encodes as %20. This scheme ensures that URLs remain unambiguous and compatible across all web servers, proxies, and browsers, regardless of the underlying character encoding of the page.
- input
- Input Text — The text to URL-encode or the percent-encoded string to decode.
- encoded
- Encoded Output — Percent-encoded string safe for use in URLs.
How to Use
- Select Encode mode to convert special characters to percent-encoding for use in URL query parameters or path segments.
- Select Decode mode to convert percent-encoded strings back to plain readable text, for example when debugging encoded URLs.
- The encoding map shows which characters in your input were encoded and what their hex codes are.
- Character counts show how encoding affects the length — strings with many special characters can grow significantly.
Understanding the Result
URL encoding (percent-encoding) replaces unsafe ASCII characters in URLs with a % followed by their two-digit hexadecimal code. For example, a space becomes %20, an ampersand (&) becomes %26, and a hash (#) becomes %23. Only alphanumeric characters (A-Z, a-z, 0-9) and the unreserved characters (- _ . ~) remain unencoded. Reserved characters like ?, /, :, @, &, =, +, $, and # must be encoded when they appear in data rather than as URL syntax delimiters.
Without percent-encoding, special characters in query parameters would break URL parsing: if a search query contains "&", the server would misinterpret it as a parameter separator, so encoding it as %26 solves this problem. Modern browsers automatically encode certain characters in the address bar, but when constructing URLs programmatically in JavaScript, encodeURIComponent() encodes query parameter values safely while encodeURI() preserves structural characters like slashes.
Frequently Asked Questions
- Why do spaces in URLs become %20?
- Spaces are not allowed in URLs because they break parsing — a URL with a space would be ambiguous. The %20 encoding is the hex representation of the space character (ASCII 32 = 0x20). In the query string portion of a URL (after the ?), a + sign may also represent a space, following the application/x-www-form-urlencoded convention from HTML forms. However, in other parts of the URL, only %20 is valid for encoding spaces.
- What characters need URL encoding?
- All characters except A-Z, a-z, 0-9, and - _ . ~ need encoding in URLs. This includes spaces, punctuation marks (quotes, brackets, commas), and special characters like & ? # % = that have structural meaning in URLs. If a query parameter value contains an &, it must be encoded as %26 or the server will interpret it as the start of a new parameter, causing data corruption.
- What is the difference between encodeURI() and encodeURIComponent()?
- encodeURI() encodes a complete URI while preserving characters that have special meaning in the URI structure, such as :, /, ?, and #. Use it when encoding an entire URL string. encodeURIComponent() encodes all characters including structural ones, making it suitable for encoding individual query parameter values. Using the wrong function can break your URL: encodeURI("page.html?q=hello&world") produces "page.html?q=hello&world" (unchanged), while encodeURIComponent("hello&world") produces "hello%26world".
Cite this calculator
TheCalcUniverse. "URL Encoder / Decoder — Free Online Calculator with Step-by-Step Guide." TheCalcUniverse, 2026, https://thecalcuniverse.com/engineering/url-encoder-decoder/. Accessed July 27, 2026.
Embed this calculator on your site
You may also like
-
Base64 Encoder / Decoder
Encode text to Base64 or decode Base64 back to text instantly. Supports text and file input with live encoding…
-
Token Converter
Estimate token counts for any text across OpenAI (cl100k_base), Claude, Llama 3, and General tokenizers. Free,…
-
Resistor Calculator
Decode 4/5/6-band resistor color codes to ohms or reverse-calculate the color bands from any resistance value.…
-
Electricity Cost
Calculate the energy cost of any electrical appliance. Pick from 20 common appliance presets or enter custom w…