Skip to content
TheCalcUniverse

URL Encode

Encode text for safe URL transmission or decode URL-encoded strings. Shows character mappings for special characters. Free, instant, and accurate.

✓ Tested formula & cited sources Formula verified 2026-01-15 Runs in your browser — inputs never sent anywhere

The formula

URL Encoding = % + hex code (e.g., space → %20)

input
Input Text
encoded
Encoded Output
Full explanation ↓

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 TextThe text to URL-encode or the percent-encoded string to decode.
encoded
Encoded OutputPercent-encoded string safe for use in URLs.
URL encoding replaces unsafe characters with % followed by their two-digit hex code for safe URL transmission.

How to Use

  1. Select Encode mode to convert special characters to percent-encoding for use in URL query parameters or path segments.
  2. Select Decode mode to convert percent-encoded strings back to plain readable text, for example when debugging encoded URLs.
  3. The encoding map shows which characters in your input were encoded and what their hex codes are.
  4. 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".
Was this calculator helpful?
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

Free to embed. Paste this into any HTML page — it stays up to date automatically.

Open embed ↗

You may also like