URL Encoder / Decoder

Safely encode or decode special characters, query strings, and parameters for URLs and REST APIs with full UTF-8 support.

USP: Percent-encoding for ASCII safety. Secure in-browser processing.

How to use URL Encoder / Decoder

Complete Technical Guide to URL Percent-Encoding & Component Decoding

The Uniform Resource Identifier (URI) and Uniform Resource Locator (URL) are the fundamental addressing mechanisms of the World Wide Web. Standardized under RFC 3986 by the Internet Engineering Task Force (IETF), URLs are restricted to a narrow subset of 7-bit US-ASCII characters. When an application attempts to pass spaces, mathematical operators, punctuation marks, emojis, or international Unicode scripts (such as Arabic, Devanagari, Japanese, or Cyrillic) through a URL query parameter or path segment, the text must be translated using Percent-Encoding (also known as URL encoding).

Our URL Encoder / Decoder provides an audited, instant, zero-latency workspace for backend software engineers, frontend web developers, SEO specialists, and REST API architects to sanitize URL parameters and decode raw network payloads directly in the browser memory.

1. The Character Taxonomy of RFC 3986: Reserved vs Unreserved

RFC 3986 partitions all available computer characters into two strict functional classes:

  • Unreserved Characters: Characters that have no syntactic meaning in URLs and are never encoded.
    • Uppercase alphabet: A through Z
    • Lowercase alphabet: a through z
    • Decimal digits: 0 through 9
    • Four literal symbols: Hyphen (-), Underscore (_), Period (.), and Tilde (~)
  • Reserved Characters: Characters that serve as delimiters to structure URL protocols, hosts, port numbers, paths, queries, and fragment identifiers. If these symbols are passed as data rather than syntax, they must be percent-encoded:
    • Query & Parameter Delimiters: Question mark (?), Ampersand (&), Equals sign (=)
    • Path & Hierarchy Delimiters: Forward slash (/), Colon (:), At sign (@)
    • Fragment Delimiters: Hash / Octothorpe (#)
    • Sub-delimiters: Dollar sign ($), Plus sign (+), Comma (,), Semicolon (;), Exclamation mark (!)

2. The Mechanics of Percent-Encoding

When a character is outside the unreserved set, it is transformed into its hexadecimal byte representation preceded by the percent symbol (%): $\text{Character} \longrightarrow \text{UTF-8 Byte(s)} \longrightarrow %\text{HH}$

Concrete Examples:
  • Space character: ASCII 32 (Hex 0x20) $\longrightarrow$ %20
  • Ampersand (&): ASCII 38 (Hex 0x26) $\longrightarrow$ %26
  • Equals sign (=): ASCII 61 (Hex 0x3D) $\longrightarrow$ %3D
  • Forward slash (/): ASCII 47 (Hex 0x2F) $\longrightarrow$ %2F
  • Question mark (?): ASCII 63 (Hex 0x3F) $\longrightarrow$ %3F
Multi-Byte UTF-8 Unicode Percent-Encoding:

For characters outside the 128-character ASCII set, UTF-8 uses 2, 3, or 4 bytes. Each byte receives its own percent sign:

  • The Euro symbol (€): UTF-8 bytes 0xE2 0x82 0xAC $\longrightarrow$ %E2%82%AC
  • The Rocket emoji (🚀): UTF-8 bytes 0xF0 0x9F 0x9A 0x80 $\longrightarrow$ %F0%9F%9A%80
  • The Spanish accented letter (é): UTF-8 bytes 0xC3 0xA9 $\longrightarrow$ %C3%A9

3. Critical JavaScript Distinction: encodeURI vs encodeURIComponent

Frontend and Node.js developers frequently introduce severe bugs by confusing these two native methods:

  • encodeURI(url) — For Full Web Addresses: Intended to encode a complete URL without destroying its network routing structure. It leaves structural reserved delimiters intact:
    • Preserves: ; , / ? : @ & = + $ #
    • Example: encodeURI("https://example.com/search?q=cats & dogs")
    • Output: "https://example.com/search?q=cats%20&%20dogs" (Note: the ampersand remains unencoded, which corrupts the query parameter parsing!)
  • encodeURIComponent(string) — For Query String Parameter Values: Intended to encode individual key or value pairs within the query string or URL hash. It aggressively encodes all reserved delimiters so that data characters cannot be mistaken for protocol syntax:
    • Encodes: ; , / ? : @ & = + $ #
    • Example: encodeURIComponent("cats & dogs")
    • Output: "cats%20%26%20dogs"
    • Engineering Rule: Always build query strings using encodeURIComponent on each parameter key and value, or use the modern URLSearchParams browser API.

4. The Space Ambiguity: %20 vs Plus Sign (+)

A common source of confusion is whether spaces should be encoded as %20 or +:

  • RFC 3986 Standard: Mandates that a space is percent-encoded as %20. This applies universally to all URI path segments, headers, and standard REST requests.
  • HTML Form POST Specification (application/x-www-form-urlencoded): Legacy HTML forms serialize spaces in query strings as +.
  • Best Practice: In modern JSON REST APIs and GraphQL endpoints, always prefer %20 to ensure universal compatibility across non-browser clients (such as cURL, Python requests, Go net/http, and mobile apps).

5. Web Security: Defending Against Parameter Pollution & Injection Attacks

Improper URL encoding exposes backend web services to critical vulnerabilities:

  • HTTP Parameter Pollution (HPP): An attacker submits an unencoded ampersand (e.g. ?role=user&role=admin). Depending on whether the server takes the first or last parameter, privilege escalation can occur.
  • Path Traversal Attacks: Failing to sanitize percent-encoded dots and slashes (%2E%2E%2F representing ../) can allow unauthorized access to server filesystem directories.
  • Open Redirect Vulnerabilities: Passing unencoded destination target URLs in redirect parameters (e.g. ?redirect=https://evil.com) can trick users into phishing domains.

Frequently Asked Questions

Why do URLs need percent-encoding?
URLs are restricted to a small subset of ASCII characters (RFC 3986). Characters outside this set (like spaces, punctuation, symbols, and non-English scripts) must be converted into %HH hexadecimal bytes so that network routers and servers can process them without parsing errors.
What is the difference between encodeURI and encodeURIComponent?
encodeURI is designed for full URLs and leaves reserved protocol delimiters like /, ?, and & untouched. encodeURIComponent is designed for individual query parameter values and encodes all reserved delimiters so that symbols like & or = are treated as content rather than parameter separators.
Should a space be encoded as %20 or as a plus sign (+)?
According to RFC 3986, spaces should be encoded as %20. The plus sign (+) is only used in legacy HTML form data submissions (application/x-www-form-urlencoded). For modern REST APIs, %20 is the universally accepted standard.
Can this tool decode malformed or corrupted URL strings?
Our decoder handles both standard percent-encoded strings and handles malformed byte sequences safely by reporting the exact character position of any syntax errors without crashing.
Does this tool encode emojis and international Unicode characters correctly?
Yes. Our engine uses standard UTF-8 multi-byte encoding. Emojis and international characters are converted into their exact 2-byte, 3-byte, or 4-byte percent-encoded triplets.
Is my encoded or decoded text transmitted across the internet?
No. All encoding and decoding operations run 100% locally inside your browser memory using native client-side JavaScript. Sensitive API keys, session tokens, and query strings are never sent to external servers.