💻 Coding

URL Encoder/Decoder

Encode or decode URLs and query parameter values, with a choice between full-URI and query-component encoding.

Presets:
Output (encoded)

      

What is URL Encoding (Percent-Encoding) and When Should You Use It?

Quick Answer: URL encoding (also known as percent-encoding) converts non-ASCII and reserved characters in web addresses into hexadecimal sequences prefixed with a percent sign (e.g., spaces become %20). Defined by RFC 3986, it prevents transmission errors and syntax confusion across web browsers, web servers, and APIs. Use Query Component mode for individual parameter values and Full URI mode when formatting a complete address.

Web addresses strictly permit only ASCII characters from a specific subset. When URLs contain international characters, spaces, or reserved syntax delimiters like ampersands (&) and question marks (?), those characters must be percent-encoded to prevent parsers from misinterpreting parameter boundaries.

RFC 3986 Character Class Reference

Character Category Characters Included Full URI (encodeURI) Query Component (encodeURIComponent) Functional Role
Unreserved A-Z, a-z, 0-9, -, _, ., ~ Preserved (Not encoded) Preserved (Not encoded) Standard data characters safe in all URI positions
Reserved (Gen-delims) :, /, ?, #, [, ], @ Preserved (Not encoded) Encoded (e.g. / -> %2F) Separates URI components (scheme, host, path, query, fragment)
Sub-delimiters !, $, &, ', (, ), *, +, ,, ;, = Preserved (Not encoded) Encoded (e.g. & -> %26) Separates query parameters and subcomponents
Whitespace & Control Space, Tab, Line breaks Encoded (%20) Encoded (%20) Unsafe in raw URLs; causes parser termination
Unicode / Emojis Non-ASCII code points (e.g., é, ✓, ☕) Encoded (UTF-8 bytes) Encoded (UTF-8 bytes) Multi-byte UTF-8 sequences converted to percent-triplets

The Critical Distinction: encodeURI vs encodeURIComponent

Modern web runtimes provide two native JavaScript functions for URL encoding with fundamentally different scopes and responsibilities:

Mechanics of UTF-8 Multi-Byte Serialization

When an international character, mathematical symbol, or emoji enters a URL, the encoding engine does not operate on Unicode code points directly. Instead, it follows a strict two-phase transformation:

  1. UTF-8 Byte Generation: The character is converted into its variable-length UTF-8 binary representation (between 1 and 4 bytes). For instance, the ASCII character A is 1 byte (0x41), the Latin character é is 2 bytes (0xC3 0xA9), the Devanagari character ॐ is 3 bytes (0xE0 0xA5 0x90), and the emoji 🚀 is 4 bytes (0xF0 0x9F 0x9A 0x80).
  2. Percent-Hex Formatting: Each individual byte is serialized as a literal percent symbol (%) followed by two uppercase hexadecimal digits. Thus, é becomes %C3%A9, and 🚀 becomes %F0%9F%9A%80.

When decoding, the parser must read the complete multi-byte sequence before reconstructing the Unicode character. If a percent-encoded string is truncated prematurely (for example, receiving %F0%9F without the trailing two bytes), browsers throw a URIError: malformed URI sequence.

Form URL Encoding (+ Signs) vs Standard RFC 3986 Percent Encoding

A frequent source of developer confusion is the difference between percent-encoding in standard URIs and the older application/x-www-form-urlencoded format used by HTML forms:

Our tool provides an interactive Space Encoding dropdown so you can conveniently toggle between RFC 3986 (%20) and form-encoded (+) outputs depending on whether you are building modern REST API calls or legacy form payloads.

Common Failure Modes in Production Pipelines

Mismanaged URL encoding causes persistent production incidents across web applications:

Security Considerations: Open Redirects, CRLF Injection, and SSRF

URL encoding plays an indispensable role in securing web endpoints against transport-level exploitation:

Cross-Platform Implementation Guide

Authoritative cheat sheet for encoding and decoding URLs across modern programming ecosystems:

Environment Component Encode Component Decode Full URI Handling
JavaScript (ES6+) encodeURIComponent(str) decodeURIComponent(str) encodeURI(str) / decodeURI(str)
Python 3 urllib.parse.quote(str, safe='') urllib.parse.unquote(str) urllib.parse.quote(str)
Go (Golang) url.QueryEscape(str) url.QueryUnescape(str) url.PathEscape(str)
PHP rawurlencode($str) rawurldecode($str) urlencode($str) (uses +)
Java URLEncoder.encode(str, StandardCharsets.UTF_8) URLDecoder.decode(str, StandardCharsets.UTF_8) URI.create(str).toASCIIString()
C# / .NET Uri.EscapeDataString(str) Uri.UnescapeDataString(str) Uri.EscapeUriString(str)

Client-Side Zero-Trust Architecture

Security and data confidentiality are critical when handling URLs that contain sensitive access tokens, OAuth authorization codes, session IDs, or personally identifiable query parameters. Utility369 executes all URL transformations, regular expression splits, and parameter extraction algorithms entirely within your web browser's local sandbox memory. No URL text or query data is transmitted across the network, stored on remote databases, or logged in server telemetry.

Frequently Asked Questions

What is the difference between Query Component and Full URI encoding?

Query Component mode (encodeURIComponent) encodes all punctuation except unreserved characters (- _ . ! ~ * ' ( )), safely escaping structural characters like / : ? & =. Full URI mode (encodeURI) preserves structural delimiters because a complete URI uses them to delineate protocol, host, path, and query parts.

Why do query parameters fail when they contain an unescaped ampersand or equals sign?

In standard URL parsing, the ampersand (&) separates distinct key-value pairs, and the equals sign (=) assigns values to keys. When raw & or = appears inside a value without component encoding (%26 or %3D), the parser breaks the value into multiple truncated parameters.

Why do some URLs use plus signs (+) instead of %20 for spaces?

RFC 3986 specifies %20 for spaces in standard URIs. However, the application/x-www-form-urlencoded format traditionally used by HTML form submissions encodes spaces as plus (+) signs. This tool supports decoding plus signs into literal spaces via a dedicated toggle.

What causes a malformed URI sequence error during URL decoding?

A malformed URI error occurs when a percent symbol (%) is not followed by two valid hexadecimal digits, or when percent-encoded bytes form an incomplete UTF-8 byte sequence due to string truncation or corruption.

Should I use encodeURI or encodeURIComponent when sending data via API?

When appending query parameter values or dynamic path segments in an API call, always use encodeURIComponent on each individual parameter. Only use encodeURI when you need to escape spaces in a complete pre-constructed URL without altering existing query strings.

Is my URL or sensitive token data transmitted to any external server?

No. All URL encoding, decoding, and query parameter parsing run entirely on your device using client-side JavaScript. No URL strings, session IDs, or private keys are ever uploaded or logged.

How does UTF-8 multi-byte encoding translate into percent-encoded sequences?

Characters outside the ASCII range are first converted into their variable-length UTF-8 binary bytes (1 to 4 bytes). Each resulting byte is then converted to its two-digit uppercase hexadecimal representation preceded by a percent symbol, such as %C3%A9 for the letter e with acute accent.

Can URL encoding prevent Cross-Site Scripting (XSS) and injection vulnerabilities?

URL encoding ensures safe transport through web addresses and query strings, but it is not a substitute for HTML entity escaping or database parameterization. When reflecting decoded values into an HTML document or SQL query, proper context-aware sanitization remains mandatory.

Why are characters like exclamation marks and tildes sometimes left unencoded?

RFC 3986 defines tilde (~), hyphen (-), underscore (_), and period (.) as unreserved characters that never require encoding. While RFC 2396 historically treated exclamation marks and asterisks as reserved sub-delimiters, JavaScript encodeURIComponent preserves them by default according to legacy ECMAScript standards.

How should nested URLs or redirect URLs inside query strings be encoded?

When passing a complete URL as a parameter value inside another URL (such as an OAuth redirect_uri or proxy target), the nested URL must be fully encoded using encodeURIComponent. This ensures slashes, colons, and question marks inside the nested URL are not mistaken for parts of the outer URL.