← Back to Blog
Developer Guides3 min read

URL Encoding Explained: What Percent-Encoding Is and Why It Matters

July 11, 2026

A URL can only contain a specific set of characters defined by the URI specification. Letters (A–Z, a–z), digits (0–9), and a small set of symbols (-, _, ., ~) are safe to use as-is. Everything else — spaces, special characters, non-ASCII letters, and symbols like &, =, ?, # — must be encoded before they appear in a URL.

What percent-encoding does

Percent-encoding (also called URL encoding) converts an unsafe character into a % sign followed by its two-digit hexadecimal ASCII code. A space becomes %20. An ampersand (&) becomes %26. A forward slash in a query parameter becomes %2F. This allows any text to be safely embedded in a URL without breaking its structure.

Characters that must be encoded

  • Spaces → %20 (or + in form data)
  • & → %26 (used as query parameter separator)
  • = → %3D (used as key-value separator)
  • ? → %3F (marks the start of the query string)
  • # → %23 (marks a fragment identifier)
  • / → %2F (path separator, when used inside a value)
  • Non-ASCII characters — accented letters, emoji, Chinese characters

When you need to encode a URL

The most common situation is building query parameters dynamically. If a user searches for "hello world", the search URL should be /search?q=hello%20world — not /search?q=hello world, which is technically invalid and may be misinterpreted.

Other situations include passing file paths or email addresses as URL parameters, building redirect URLs that contain other URLs as values, and constructing API requests programmatically.

When you need to decode a URL

Decoding is useful when you receive an encoded URL and want to read the original content. API responses, server logs, browser address bars, and copied links often contain percent-encoded strings that are hard to read at a glance. Decoding reveals the original human-readable values.

URL encoding vs Base64

Both URL encoding and Base64 convert data for safe transmission, but they serve different purposes. URL encoding keeps text readable and URL-safe by replacing specific characters. Base64 converts binary data into a compact text format. Use URL encoding for query parameters and URL components. Use Base64 when you need to embed binary data like files or images.

Try it yourself

Free online URL Encoder and Decoder

Use Toolzmint's URL Encoder and Decoder right in your browser — no install, no sign-up required.

Open URL Encoder and Decoder