DevDash

URL Encoder & Decoder

Encode, decode, and parse URLs in your browser.

Paste a URL to encode, decode, or break it down into its components.

Mode:

About URL Encoding

URL encoding, formally known as percent-encoding, is the mechanism defined by RFC 3986 for representing characters in a URI that are not allowed or have special meaning. Each unsafe character is replaced by a percent sign (%) followed by two hexadecimal digits representing the character's byte value. For example, a space becomes%20, an ampersand becomes%26, and a forward slash becomes%2F.

Which Characters Are Safe?

The unreserved characters that never need encoding are uppercase and lowercase letters (A-Z, a-z), digits (0-9), hyphen (-), underscore (_), period (.), and tilde (~). Reserved characters like: / ? # [ ] @ ! $ & ' ( ) * + , ; = have special structural meaning in URLs and must be percent-encoded when used as literal data within a URL component.

encodeURI vs encodeURIComponent

JavaScript provides two built-in functions for URL encoding, and choosing the wrong one is a common source of bugs. encodeURI is designed to encode a complete URL — it encodes unsafe characters but preserves reserved characters like:,/,?, and#that form the URL's structure. encodeURIComponent encodes everything except unreserved characters, making it the correct choice for encoding individual query parameter keys and values. Using encodeURI on a parameter value that contains & or= will break the query string structure.

Common Pitfalls: Double Encoding

Double encoding happens when an already-encoded string is encoded again, turning%20 into%2520 (the% itself gets encoded as%25). This typically occurs when encoding is applied at multiple layers of an application — for example, manually encoding a value before passing it to a library that also encodes it. To avoid this, encode values once at the point where the URL is constructed, and decode once at the point where the value is consumed.

URL Structure

A complete URL follows the structure:scheme://host:port/path?query#fragment. The scheme (e.g., https) identifies the protocol. The host identifies the server. The path points to a specific resource. The query string starts with ? and contains key-value pairs separated by &. The fragment starts with # and identifies a section within the page — it is never sent to the server. Understanding this structure is essential for knowing which parts of a URL need encoding and which encoding function to use.

Frequently Asked Questions

What is URL encoding?

URL encoding (percent-encoding) converts special characters into a %XX hex format so they can be safely transmitted in URLs. Characters like spaces, ampersands, and non-ASCII characters are replaced with a percent sign followed by their two-digit hexadecimal byte value, ensuring the URL structure is not broken by literal special characters.

Why do URLs have %20 for spaces?

Spaces are not valid characters in URLs according to RFC 3986. The hexadecimal value of the space character (ASCII 32) is 20, so it is percent-encoded as %20. In HTML form submissions, spaces may also appear as + signs, but %20 is the universally correct encoding for spaces in URL paths and query parameters.

What is the difference between encodeURI and encodeURIComponent?

encodeURI preserves URL structure characters like :, /, ?, and # — use it to encode a complete URL. encodeURIComponent encodes everything except unreserved characters (letters, digits, -, _, ., ~), making it the correct choice for encoding individual query parameter keys and values where those structural characters should be treated as literal data.

What characters need to be URL encoded?

Characters that must be percent-encoded when used as data in URLs include spaces, &, =, ?, #, +, and all non-ASCII characters. Reserved characters like : and / only need encoding when they appear as literal values within a URL component rather than serving their structural role in the URL syntax.

How do I decode a URL?

Use decodeURIComponent() in JavaScript to convert percent-encoded sequences back to their original characters. In Python, use urllib.parse.unquote(). You can also paste an encoded URL into an online decoder tool like this one. Use decodeURI() instead if you want to preserve the URL's structural characters while decoding the rest.