URL Encoder / Decoder

Encode or decode text for URLs and query strings, and see exactly which characters turn into which percent codes.

Encoding uses encodeURIComponent(), which escapes separators such as &, = and /. That is the right choice for a single value, not for a complete URL.

Encoded or decoded output

Decoding reverses the percent codes and rebuilds the original UTF-8 text.

Percent-encoding quick reference

Character Code Role in a URL
Space%20Not allowed raw in a URI
&%26Separates query parameters
=%3DSeparates a name from its value
?%3FStarts the query string
#%23Starts the fragment
/%2FSeparates path segments
+%2BLiteral plus in a value
%%25Introduces every escape

Rate this Tool

0.0/5

Based on 0 user ratings.

Percent-encoding turns characters into safe bytes

A URL is a structured text format with reserved separators. Encoding protects a value so that its content cannot be mistaken for that structure.

What percent-encoding does

The URI standard divides characters into two groups. Unreserved characters are always safe: letters A-Z and a-z, digits 0-9, hyphen, period, underscore and tilde. Reserved characters have a syntactic meaning, such as / in a path or & between query parameters. Everything else must be escaped before it can travel inside a URL.

An escape is a percent sign followed by two hexadecimal digits that represent one byte. A space is byte 32 in ASCII, which is 20 in hex, so a space becomes %20. The two digits are case-insensitive: %2f and %2F are the same escape, although uppercase is the common convention.

Encoding is not encryption and it is not compression. It is a reversible transport rule. Anyone can decode a URL, and decoding does not require a key.

encodeURIComponent vs encodeURI

JavaScript ships two functions with similar names and very different jobs. encodeURIComponent() escapes everything except the unreserved set plus a few sub-delimiters that are harmless in a value: ! ~ * ' ( ). It is designed for one parameter value, one path segment or one fragment.

encodeURI() keeps the characters that give a URL its structure, including ; , / ? : @ & = + $ #. It is designed for a complete URL that is already assembled and only contains stray spaces or non-ASCII text.

InputencodeURIComponent()encodeURI()
a ba%20ba%20b
a&b=ca%26b%3Dca&b=c
/docs/a b%2Fdocs%2Fa%20b/docs/a%20b
cafécaf%C3%A9caf%C3%A9

The rule of thumb is simple: encode the pieces, then join them with the separators you wrote yourself. Running encodeURIComponent() on a whole URL turns https://example.com/a into https%3A%2F%2Fexample.com%2Fa, which is no longer a URL but a single path segment.

Query strings, paths and form data

Each part of a URL has its own rules. The scheme and host are not percent-encoded. The path is a sequence of segments separated by /. The query begins after ? and carries name-value pairs separated by & and joined by =. The fragment begins after # and is handled by the browser, not sent to the server.

scheme https:// host example.com path /search/ query ?q=red shoes frag #top segment values: %20 %2F %3F parameter values: %20 %26 %3D Separators stay. Values inside each part are encoded.

HTML forms add a wrinkle. When a form is submitted with the default application/x-www-form-urlencoded type, spaces are sent as + rather than %20. A query parser that follows that convention turns + back into a space, which is why a literal plus sign must be encoded as %2B. decodeURIComponent() does not convert + to a space, so a value read from a form can look wrong if the plus is not handled separately.

A query value is everything after the first = and before the next &. If the value itself contains &, it must be encoded as %26, otherwise the server sees an extra parameter. In JavaScript, URLSearchParams applies the form rules for you: it escapes the values and writes a space as +. Building the same string by hand with encodeURIComponent() writes a space as %20. Both forms are valid query strings, but the server must decode them with matching rules.

Unicode, UTF-8 and multi-byte escapes

Percent-encoding works on bytes, not on characters. A non-ASCII character is first encoded as UTF-8, then each byte becomes its own escape. That is why accented letters and emoji produce several escapes instead of one.

TextUTF-8 bytesPercent-encoded
éC3 A9%C3%A9
ñC3 B1%C3%B1
中E4 B8 AD%E4%B8%AD
😀F0 9F 98 80%F0%9F%98%80

Decoding a byte sequence with the wrong character set produces mojibake, the familiar sequence of accented gibberish. The escapes themselves do not declare an encoding; the receiving application has to know that UTF-8 was used. Modern web pages declare it with <meta charset="utf-8">, and JSON uses UTF-8 by default.

Decoding safely and avoiding double encoding

Decoding is strict. A percent sign that is not followed by two hexadecimal digits is invalid, and JavaScript throws a URIError in that case. The tool reports the error instead of returning a partial string, because a silent partial decode hides the real problem.

Double encoding is the most common accident. If a b is encoded to a%20b and then encoded again, the percent sign is escaped to %25 and the result is a%2520b. The server decodes it once and still sees a%20b, so the visible value keeps the escape instead of the space.

encodeURIComponent('a b') → a%20b encodeURIComponent('a%20b') → a%2520b decodeURIComponent('a%2520b') → a%20b

Decide once where encoding happens. A common pattern is to encode when the URL is built and never again in the HTTP client, unless that client documents that it encodes the URL itself.

Common URL encoding errors

ErrorSymptomFix
Encoding the whole URLhttps%3A%2F%2F... appears in the address barEncode only the values
Double encoding%2520 or %2526 in the requestEncode once, at the boundary
Leaving & unencoded in a valueThe server receives an extra parameterEscape it as %26
Assuming + means space everywhereA literal plus disappears or becomes a spaceUse %2B for a literal plus
Truncated escapeURIError: URI malformedKeep all six characters of %C3%A9
Unencoded non-ASCIIWorks in one browser, breaks in anotherEncode to UTF-8 percent escapes

The URI standard does not define a maximum length. Practical limits come from browsers, proxies and servers, and they differ. Very long query strings are usually a sign that the data belongs in a request body rather than in the URL.

Related Developer & Security Tools

Tool What does it do? Action
Base64 Encoder & Decoder Encode text to Base64 or decode a Base64 string back to plain text. Base64 Codec →
Hash Generator Create MD5, SHA-1, SHA-256 and SHA-512 hashes from text. Hash Maker →
UUID Generator Generate random UUID v4 values, one or many at a time. UUID Maker →
Password Generator Build strong random passwords with length and character options. Password Maker →
Regex Tester Test a regular expression against sample text and inspect the matches. Regex Test →
JWT Decoder Decode a JWT header and payload locally, without sending the token anywhere. JWT Decode →

Frequently Asked Questions

URL encoding replaces characters that are not allowed, or that have a structural meaning, with a percent sign and two hexadecimal digits representing the UTF-8 byte. A space becomes %20 and & becomes %26.

Use encodeURIComponent() for a single value, path segment or parameter, because it escapes separators such as & and =. Use encodeURI() only for a complete URL whose structure is already correct.

HTML form submissions use application/x-www-form-urlencoded, where + represents a space. Parsers that follow that convention decode it as a space. To keep a literal plus, encode it as %2B.

Encoding works on bytes. A character such as é takes two bytes in UTF-8, C3 and A9, so it becomes %C3%A9. Four-byte characters such as emoji produce four escapes.

No. Encoding is a reversible transport rule with no key and no secrecy. Anyone who receives the URL can decode it. Sensitive data should be protected with HTTPS and, when it must be stored, with encryption.

No. Encoding and decoding run in JavaScript on the page, so the text is not uploaded to a server and disappears when you close or reload the tab.