Skip to content

URL Encoder / Decoder

URL Encoder / Decoder

URLs can only safely contain a specific set of ASCII characters. Anything outside that set — spaces, quotes, curly braces, emoji, non-Latin characters — must be percent-encoded (converted to %XX hex notation). This tool handles both directions: encode plain text for safe URL use, or decode a percent-encoded URL back to readable text.

Why Percent-Encoding Exists

The original URL specification (RFC 1738, later refined by RFC 3986) restricts the unreserved character set to letters, digits, and a small handful of punctuation: -._~. Reserved characters like ?, #, &, /, and = have structural meaning — they delimit the URL's parts. Anything else has to be encoded as the byte's hex value prefixed with a percent sign. A space becomes %20, an emoji becomes a multi-byte UTF-8 sequence like %F0%9F%8E%89, and a Chinese character becomes a three-byte sequence.

The split between unreserved, reserved, and to-be-encoded is the source of most URL bugs. A search query containing a + is a real example: RFC 3986 lists it as a reserved sub-delimiter that a path may contain literally, while in a form-encoded query string + is interpreted as a space by historical convention. This is why encodeURIComponent encodes + but encodeURI doesn't.

Component vs Whole URI Encoding

Component mode (encodeURIComponent) escapes everything except a small safe set. Use it for individual URL parts like query string values, path segments, or fragment identifiers — anything you're inserting into a URL you're building. Whole URI mode (encodeURI) leaves structural characters (:/?#[]@!$&'()*+,;=) alone. Use it when you have a complete, already-structured URL that just needs its non-ASCII characters escaped.

The decoder reverses both. It accepts a percent-encoded string, parses each %XX sequence as a byte, decodes the byte stream as UTF-8, and returns the result. Malformed sequences (a lone % or invalid hex digits) get reported rather than silently producing garbage.

Common Use Cases

Building a query string by hand when your HTTP library is being uncooperative. Reading a URL from a log file or analytics export where everything has been encoded twice (run the decoder twice). Debugging why a link with an apostrophe in the path is breaking — the answer is almost always that someone forgot to encode it. Pair with the JSON formatter when the encoded URL was part of a JSON-encoded API response, and with the HTML entity encoder when a URL appears inside HTML attribute values.

Worked example: the same text, three encoders

The tool calls the browser's own encodeURIComponent (Component) or encodeURI (Whole URI), and the matching decode functions. On October 12, 2026 we ran six strings through both in Node and compared them with URLSearchParams, which is how browsers build form-style query strings.

InputComponentWhole URIURLSearchParams (form)
café & crèmecaf%C3%A9%20%26%20cr%C3%A8mecaf%C3%A9%20&%20cr%C3%A8mecaf%C3%A9+%26+cr%C3%A8me
a+b c/d?x=1#fa%2Bb%20c%2Fd%3Fx%3D1%23fa+b%20c/d?x=1#fa%2Bb+c%2Fd%3Fx%3D1%23f
!*'()~!*'()~ (unchanged)!*'()~%21*%27%28%29%7E
100% sure100%25%20sure100%25%20sure100%25+sure
🎉 (1 emoji, 4 UTF-8 bytes)%F0%9F%8E%89 (12 chars)samesame
🇯🇵 (flag = 2 code points)%F0%9F%87%AF%F0%9F%87%B5 (24 chars)samesame

Sources

Checked on .

Frequently Asked Questions

What's the difference between encodeURI and encodeURIComponent?+
encodeURIComponent escapes everything that isn't alphanumeric or -_.!~*'() — use it for query string values and individual URL parts. encodeURI preserves URL structure (/ ? # & = +) and only escapes truly unsafe characters — use it on a complete URL you don't want to break.
Why does a space become %20 sometimes and + other times?+
In URL paths and with encodeURIComponent a space is %20. Form-encoded query strings (application/x-www-form-urlencoded, what URLSearchParams and HTML forms produce) use + instead. This tool's decoder only undoes %XX sequences, so a + stays a +; decode form data with URLSearchParams or replace + with %20 first.
Can I encode emoji and non-Latin characters?+
Yes. Each character is encoded as its UTF-8 bytes, three characters per byte: a single emoji such as 🎉 is 4 bytes and becomes 12 characters (%F0%9F%8E%89), and a flag made of two code points becomes 24.
Is my URL sent to any server?+
No. All encoding and decoding happens in your browser using native JavaScript functions. No data is transmitted anywhere.
What’s the difference between encodeURI and encodeURIComponent?+
encodeURI preserves URL structure characters (: / ? # & =) so it can encode an entire URL; encodeURIComponent encodes them as percent-codes, so it’s safe for query parameter VALUES but would break a whole URL. The tool offers both modes explicitly.
Why are spaces sometimes %20 and sometimes +?+
%20 is the canonical form everywhere. + is a legacy shorthand used only inside application/x-www-form-urlencoded form data (query strings). Both are valid in their respective contexts.
How do I encode non-ASCII characters?+
They’re encoded as UTF-8 bytes, then each byte is percent-encoded. So "café" becomes "caf%C3%A9". The tool handles this automatically — paste any Unicode text.
Will repeatedly encoding the same string be safe?+
No. Encoding twice turns %20 into %2520, which a server reads as the literal text %20. The tool does not detect already-encoded input, so if the text already contains %XX sequences, decode it first and check the result before encoding.

📖 Learn More

Related Guide URL Encoding and Decoding: Complete Guide →

Built by Derek Giordano · Part of Ultimate Design Tools

Privacy Policy · Terms of Service