URL Encode/Decode

Convert text to and from URL-encoded format using various methods.

Conversion result will appear here

Input: 0 chars

Options for Mode: Component (encodeURIComponent)

About URL Encoding/Decoding

URL encoding (also known as percent-encoding) is a mechanism for translating unprintable or special characters into a format that can be safely transmitted over the Internet within a Uniform Resource Identifier (URI). This tool provides different encoding modes to suit various needs, following RFC 3986 where applicable.

When to Use URL Encoding

  • When creating URLs containing non-ASCII characters or special characters from the reserved set.
  • When submitting form data via HTTP requests (especially GET).
  • When passing data in query strings or path segments that contain reserved characters (&, =, ?, :, /, etc.) or other characters like spaces.
  • When working with APIs that require properly encoded parameters.

Key Concepts:

  • **Unreserved Characters:** `A-Z a-z 0-9 - _ . ~` These characters are never encoded.
  • **Reserved Characters:** `! * ' ( ) ; : @ & = + $ , / ? # [ ]` These characters *may* need encoding depending on their context within the URI.
  • **Percent-Encoding:** Characters requiring encoding are represented as `%` followed by the two-digit hexadecimal representation of their byte value (in UTF-8). For example, a space ` ` becomes `%20`.
  • **URI vs Component:**
    • `encodeURI()`: Encodes a *full* URI. It encodes reserved characters *only* if they are not part of a standard URI component structure (like encoding a `#` or `?` inside a path segment where they aren't delimiters).
    • `encodeURIComponent()`: Encodes a *part* of a URI, like a query string value or a path segment. It encodes *all* reserved characters, spaces, etc. It is the most common function for encoding values.
  • **Form URL Encoded:** The `application/x-www-form-urlencoded` format (used for HTML form submissions with `method="GET"` or `POST"`) specifically replaces spaces with `+` characters instead of `%20`. Other characters are encoded using percent-encoding based on UTF-8.