What is URL Encoding?

URL encoding — also called percent-encoding — converts special characters in a URL into a safe format using a percent sign followed by two hexadecimal digits.

Definition

URLs may only contain a specific set of ASCII characters. Any character outside that set — including spaces, non-ASCII letters, and characters with special meaning in URLs — must be encoded. Encoding replaces the character with % followed by its hexadecimal ASCII code.

Common Encodings

  • Space → %20
  • &%26
  • =%3D
  • ?%3F
  • /%2F
  • #%23
  • +%2B

%20 vs + for Spaces

%20 is the standard encoding for a space in any part of a URL. A + represents a space specifically in query strings (application/x-www-form-urlencoded format — the default for HTML form submissions). In URL paths, + is a literal plus sign.

Why It Matters

Characters like & and = have structural meaning in query strings. If your data contains an &, encoding it as %26 prevents it being misread as a parameter separator. Without encoding, URLs become ambiguous and can cause bugs or security issues.

Encode or decode URLs instantly in your browser: Open URL Encode / Decode →

Frequently Asked Questions

Is URL encoding the same as Base64?

No. URL encoding preserves the meaning of characters while making them URL-safe. Base64 converts binary data to an ASCII string. They are different transformations for different purposes.

Do I need to encode the entire URL?

No. Only individual components (query parameter values, path segments) should be encoded. Encoding the entire URL would also encode the slashes and colons that form its structure.

Related Terms

  • Base64 — Another encoding scheme — different purpose, different format.
  • URL Slug — The human-readable portion of a URL path.