URL Encoder/Decoder

URL Encoder/Decoder converts special characters to percent-encoded equivalents. Essential for web development and handling URLs with spaces or special characters.

Free online tool · Developer Tools · No installation · No sign-up required

Overview

URL encoding, also known as percent-encoding, is a crucial mechanism for ensuring that web addresses (URLs) are transmitted and interpreted correctly across the internet. It works by converting characters that are not part of the standard, safe ASCII character set into a format that can be universally understood. This process is essential because URLs have a restricted character set, and certain characters have special meanings. For instance, the ampersand (&) is used to separate parameters in a query string. If a parameter value itself contains an ampersand, it must be encoded to prevent it from being misinterpreted as a parameter separator. The encoding process replaces unsafe characters with a percent sign (%) followed by a two-digit hexadecimal representation of the character\'s ASCII or UTF-8 value. This ensures data integrity and prevents misinterpretation by web browsers and servers, making the web a more reliable and predictable environment.

The technical workings of URL encoding are straightforward yet vital for web functionality. When a character needs to be encoded, it is replaced by a three-character sequence: a percent sign (%) followed by the two hexadecimal digits representing the character\'s value in the ASCII or UTF-8 character set. For example, a space character is encoded as `%20`, and a forward slash (/) becomes `%2F`. This process is not just for special characters but also for non-ASCII characters, which are common in many languages. By converting these characters into a universally accepted format, URL encoding allows for the seamless transmission of international characters in URLs. This standardization is defined by RFC 3986, which specifies which characters are reserved, unreserved, and which must be percent-encoded, providing a clear and consistent framework for web developers and browser manufacturers to follow.

The importance of URL encoding extends beyond just ensuring that URLs are correctly formatted. It plays a significant role in web security by preventing a class of vulnerabilities known as URL injection attacks. Malicious actors can manipulate URLs by injecting special characters to perform unauthorized actions, such as accessing restricted data or executing harmful commands on a server. Proper URL encoding neutralizes these threats by ensuring that user-supplied data is treated as literal data and not as part of the URL\'s structure. This is particularly important in web applications that dynamically generate URLs based on user input. By consistently applying URL encoding, developers can safeguard their applications against these attacks, protect user data, and maintain the overall integrity and security of their web services. It is a fundamental practice for building robust and secure web applications.

Worked example

One search value encoded three ways

A search box sends the value cafe com leite & 50% off, and the same value also has to appear inside a full URL and inside a form post.

  1. With Encode mode and Encode Type Component, the value becomes caf%C3%A9%20com%20leite%20%26%2050%25%20off. The space is %20, the ampersand is %26 and the percent sign is %25.
  2. Switch to Form and the same input becomes caf%C3%A9+com+leite+%26+50%25+off: spaces turn into plus signs and the punctuation that encodeURIComponent leaves alone, including ! ( ) ~ and *, is escaped as well.
  3. Paste the whole URL, https://example.com/busca?q=cafe com leite&page=2, and switch Encode Type to Full. The result is https://example.com/busca?q=caf%C3%A9%20com%20leite&page=2, with the colon, slashes, question mark and ampersand untouched because a full URL needs them.
  4. Encode the same URL with Component selected and every separator is destroyed: https%3A%2F%2Fexample.com%2Fbusca%3Fq%3Dcaf%C3%A9%20com%20leite%26page%3D2. That string is a value, not a URL.
  5. Switch to Decode with Full selected to reverse it: decodeURI leaves reserved sequences alone, which is exactly what decoding a whole URL requires, while decodeURIComponent is used for a single component.
  6. The Query Parameter Builder does the same work field by field: keys and values are encoded for you, only the key is trimmed, and a space in a value stays meaningful.

Result: The query value is caf%C3%A9%20com%20leite%20%26%2050%25%20off, the form-encoded version is caf%C3%A9+com+leite+%26+50%25+off, and the full URL keeps its separators as https://example.com/busca?q=caf%C3%A9%20com%20leite&page=2. Choosing the wrong type is the difference between a working link and a dead one.

How to use URL Encoder/Decoder

  1. Enter URL or text
  2. Click Encode or Decode
  3. View result
  4. Copy to clipboard

Common mistakes

Encoding a whole URL with the Component type and then wondering why the link 404s.

Component is encodeURIComponent, which escapes colon, slash, question mark, ampersand, equals and hash. Use Full for a complete URL, or let the Query Parameter Builder build the separators while it encodes only the keys and values.

Encoding a value that is already percent-encoded.

Encoding a value that contains %20 a second time produces %2520, and the server sees a literal percent-two-zero. The tool raises a double-encoding warning when the input already contains a percent escape; if you meant to read the value, switch to Decode instead of encoding again.

Using Form encoding for a path segment.

Form mode turns a space into a plus sign, which is correct inside a query string and wrong in a path, because a plus in a path is a literal plus. Use Component for path segments and Form only for query-string keys and values.

Expecting a lone percent sign or a truncated sequence such as %2 to decode.

Malformed percent-encoding throws, and the panel explains that a lone % or a truncated sequence cannot be decoded. In the batch box the affected line is replaced with an error marker so the remaining lines still process.

Features

Limits worth knowing

When to use it

Practical tips

Why use this tool

When this is not the right tool

Frequently asked questions

URL encoding?

Converting special characters to percent format (space = %20).

When needed?

URLs with spaces, special characters, or non-ASCII characters.

Which characters?

Spaces, &, =, ?, #, non-ASCII. Letters, numbers, -_.~ are safe.

Same as HTML encoding?

No, URL uses %20, HTML uses &.

Related tools in Developer Tools

Further reading

URL Encoder/Decoder: Encode and Decode URLs Online

Encode special characters in URLs or decode encoded URLs. Essential for web development and API work.