🔗
← Back to Guides

What Is URL Encoding? A Complete Guide to Percent-Encoding

· Tags: url-encoding, percent-encoding, web-development, url-encoder, beginner-guide

URL encoding, also known as percent-encoding, is a mechanism for encoding information in a Uniform Resource Identifier (URI) under certain circumstances. It converts characters that are not allowed in a URL into a safe format using percent signs followed by two hexadecimal digits.

Why URL Encoding Exists

The internet was built on ASCII, which only defines 128 characters. URLs must be safely transmitted across systems that may not handle non-ASCII or special characters correctly. URL encoding ensures that any character — spaces, Unicode characters, or special symbols — can be safely included in a URL.

For example:

  • Space → %20
  • @%40
  • 你好%E4%BD%A0%E5%A5%BD

Reserved vs Unreserved Characters

RFC 3986 defines two categories of characters in URLs:

Unreserved characters (never need encoding): A-Z a-z 0-9 - _ . ~

Reserved characters (have special meaning, need encoding when used literally): : / ? # [ ] @ ! $ & ' ( ) * + , ; =

When a reserved character is intended to be part of the data rather than URL structure, it must be percent-encoded.

When to Use Each Encoding Function

  • encodeURI: Encode a full URL, preserving structural characters
  • encodeURIComponent: Encode a single URL parameter or component value

Using the wrong function is one of the most common bugs in web development. Try our URL encoder/decoder to experiment with both modes.