Back to Blog
Developer Tools

URL Encoding Explained: What Are %20 and + in URLs?

2025-09-05 5 min read

URLs can only contain certain characters โ€” everything else must be percent-encoded. This guide explains URL encoding rules, common encoded characters, and how to decode them.

You've seen %20 and %2Fin URLs. You've wondered why some spaces become + and others become%20. URL encoding has specific rules โ€” here's the complete explanation.

Why URLs Need Encoding

URLs can only contain a safe subset of ASCII characters. Spaces, special characters, and non-ASCII characters (like Hindi or Arabic text) must be encoded to be transmitted safely in a URL. This is called percent-encoding.

How Percent-Encoding Works

Non-safe characters are replaced with a % followed by the two-digit hexadecimal ASCII code of the character. Space (ASCII 32) โ†’ %20. Slash (ASCII 47) โ†’ %2F. Question mark (ASCII 63) โ†’ %3F.

%20 vs + for Spaces

This is the most common confusion. In a URL path,%20 represents a space. In a query string (after the ?), the + sign is also used for spaces (legacy HTML form encoding). Modern practice prefers %20everywhere for consistency.

Characters That Don't Need Encoding

These characters are URL-safe and don't need encoding: A-Z a-z 0-9 - _ . ~

In Code

// JavaScript
encodeURIComponent("Hello World!") // "Hello%20World%21"
decodeURIComponent("Hello%20World%21") // "Hello World!"

Encode and decode URLs with our URL Encoder/Decoder tool.

url-encoding percent-encoding developer http

More Articles