>_ MoriDev dev.moritools.com
RFC 3986 · WHATWG 100% Client-Side · Zero Upload

URL Encoder, Decoder & Query String Parser

Percent-encode or decode URLs using encodeURIComponent/encodeURI and dissect protocol, host, path, hash, and query key-value tables.

Ready (Offline)
Quick Summary

Encode query values safely with encodeURIComponent, preserve structural delimiters with encodeURI, decode percent-escaped UTF-8 strings, and inspect every component and query key-value pair of a full URL.

OAuth redirect URIs, UTM tracking links, and webhook callback URLs frequently fail with 400 or signature mismatch errors because a single unencoded ampersand (&) or plus sign (+) splits a query parameter in half.

This tool pairs RFC 3986 percent-encoding with the browser WHATWG URL parser, decomposing any link into protocol, credentials, hostname, port, pathname, hash fragment, and a tabular list of decoded query string entries.

URL Encoding & Query Parsing Bugs

01. Using encodeURI() on Individual Query Parameter Values

encodeURI intentionally leaves &, =, ?, +, and / untouched because they structure full URLs. Always use encodeURIComponent() for query values like redirect_uri=https://app.example.com/cb?a=1&b=2.

02. Plus Sign (+) Versus %20 Space Ambiguity

application/x-www-form-urlencoded forms encode spaces as +, whereas RFC 3986 path segments encode spaces strictly as %20. Treating + as space inside a path segment breaks filenames like "c++ guide.pdf".

03. Malformed Percent Sequences Throwing URIError

Raw percentage signs such as "50% off" crash decodeURIComponent with URIError. Encode standalone % as %25 before placing user input into query strings.

encodeURIComponent vs encodeURI Character Behavior

Characters encodeURI encodeURIComponent
Unreserved (A-Z 0-9 - _ . ! ~ * ' ( )) Left untouched Left untouched
Structural (: / ? # @ ; , = + $ &) Preserved verbatim Percent-encoded (%3A %2F %3F %26)
Spaces & Quotes Encoded (%20 %22) Encoded (%20 %22)
UTF-8 Multibyte (中文, 🚀) UTF-8 hex octets (%E4%B8%AD) UTF-8 hex octets (%E4%B8%AD)

Worked Engineering Examples

Safely Embedding a Callback URL Inside redirect_uri

Input
https://dev.moritools.com/callback?next=/settings&tab=keys
Output
https%3A%2F%2Fdev.moritools.com%2Fcallback%3Fnext%3D%2Fsettings%26tab%3Dkeys

encodeURIComponent escapes ?, =, and & so the outer OAuth server treats the nested URL as one atomic parameter.

Unpacking Duplicate Query Keys

Input
https://api.example.com/items?tag=ts&tag=rust&limit=25#top
Output
hostname: api.example.com · pathname: /items · params: [tag=ts, tag=rust, limit=25] · hash: #top

URLSearchParams preserves repeated keys in order rather than overwriting earlier entries.

Frequently Asked Questions

When should I choose encodeURI instead of encodeURIComponent?

Use encodeURI only when encoding an entire URL that already has valid scheme, slashes, and query delimiters. For individual query parameter keys or values, always use encodeURIComponent.

Why did decoding replace "+" with a space in Component mode?

HTML forms and URLSearchParams serialize spaces as "+" in query strings. Component Decode normalizes "+" to space before running decodeURIComponent, while Full URI mode preserves literal plus signs.

Can I inspect a relative query string without a domain?

Yes. Pasting "?foo=bar&lang=en" automatically parses its query parameters into the key-value table.

Does the URL parser reveal fragments (#hash)?

Yes. The fragment identifier is extracted cleanly even though browsers never transmit the #hash segment to web servers in HTTP requests.

Continue Your Workflow

24 offline developer utilities