What is URL Encoding?

URL encoding (also known as percent encoding) is a mechanism for converting characters into a format that can be transmitted safely over the internet. In a URL, certain characters have special meaning — reserved characters like /, ?, &, and = are used to structure web addresses. When you need to include these characters as part of a value (for example, a comma in a search query), URL encoding transforms them into a safe, standardized format.

URL encoding replaces unsafe ASCII characters with a % sign followed by two hexadecimal digits. For instance, a space becomes %20, and a comma becomes %2C. If you have ever seen a URL like https://example.com/search?q=hello%20world, you have seen URL encoding in action — the %20 represents the space between "hello" and "world".

The practice is defined in RFC 3986 (Uniform Resource Identifier Syntax) and is a fundamental building block of the modern web. Every time your browser sends a request, it automatically encodes the URL to ensure the server receives exactly what you intended.

💡 Did you know? When you search "2c url encoding" on Google, you are actually looking up the %2C code — the URL-encoded form of a comma. This is one of the most commonly encountered percent-encoded characters.

Why URLs Need Encoding

URLs are restricted to a small subset of ASCII characters. The original internet standards were designed in an era where text was almost exclusively English ASCII, and the rules have stuck. Here is why encoding is necessary:

Special Characters

The URL syntax reserves certain characters as delimiters. For example, / separates path segments, ? starts the query string, and & separates query parameters. If your data contains these characters, they must be encoded to avoid breaking the URL structure. A search for "cats & dogs" becomes ?q=cats%20%26%20dogs — the & is encoded as %26 so the server does not interpret it as a parameter separator.

Non-ASCII Characters

Characters outside the basic ASCII set — such as accented letters (é, ü, ñ), symbols (€, £), and non-Latin scripts (Cyrillic, Chinese, Arabic) — cannot appear in URLs directly. They must be encoded as UTF-8 bytes and then percent-encoded. For instance, the Spanish word cómo becomes c%C3%B3mo — the ó is encoded as the two UTF-8 bytes C3 B3, which are then represented as %C3%B3.

If you work with multilingual content, use a Remove Accents tool to strip diacritics and simplify text before URL processing.

Spaces and Unsafe Characters

Spaces are not allowed in URLs. They must be encoded as %20 (or sometimes + in query strings, depending on the encoding standard). Other unsafe characters include quotation marks, angle brackets, backticks, and the # character (which starts a fragment identifier).

Raw: https://example.com/search?query=hello world & more
Encoded: https://example.com/search?query=hello%20world%20%26%20more

Common URL Encoding Characters

Here is a quick reference table of the most common percent-encoded characters you will encounter:

Character Encoded Value Common Use
Space%20Separating words in queries
, (comma)%2CList values, CSV parameters
= (equals)%3DValues containing = sign
& (ampersand)%26Preventing param splitting
? (question mark)%3FLiteral ? in query values
/ (slash)%2FPath-like values in params
# (hash)%23Preventing fragment parsing
% (percent)%25Encoding the escape char itself
: (colon)%3AProtocol-relative values
@ (at sign)%40Email addresses in URLs
+ (plus)%2BPreventing space interpretation

This table covers the most frequently seen encodings. If you need to encode or decode any character, our URL Encoder tool handles everything automatically.

How to Encode and Decode URLs

URL encoding and decoding can be done manually, through browser developer tools, or with online tools. Here are the most common approaches:

Using an Online URL Encoder

The simplest method is to use a dedicated tool. Our URL Encoder guide provides a browser-based encoder and decoder that works entirely client-side — your data never leaves your device. Paste any text, click encode, and get the percent-encoded result instantly.

Using JavaScript in the Browser Console

You can encode and decode URLs directly in your browser's developer tools:

Encode: encodeURIComponent('hello world & more')hello%20world%20%26%20more
Decode: decodeURIComponent('hello%20world')hello world

Use encodeURI() and decodeURI() if you want to encode entire URLs without touching reserved characters like /, ?, and & that are part of the URL structure.

Using Python on the Server

Python's standard library includes urllib.parse for URL encoding:

Encode: urllib.parse.quote('hello world')hello%20world
Decode: urllib.parse.unquote('hello%20world')hello world

Encode or decode any URL in seconds — free, fast, and private.

Try URL Encoder →

URL Encoding vs URL Slug Generation

URL encoding and slug generation are two different concepts that beginners often confuse. Here is how they differ:

URL encoding preserves data. It transforms unsafe characters into percent-encoded sequences so that the original value can be transmitted safely and decoded back to its original form. Encoding is reversible — %20 always decodes back to a space.

Slug generation (also called URL slugification) transforms text for readability and SEO. It removes special characters, replaces spaces with hyphens, converts to lowercase, and shortens the result. Slug generation is destructive — once you convert "Hello World!" to hello-world, you cannot recover the original casing or exclamation mark.

Use URL encoding when you need to pass data through query parameters or URL segments and need it back intact. Use a Slug Generator when you are creating human-readable, SEO-friendly URL paths.

URL Encoding: Hello World!Hello%20World%21 (reversible)
Slug: Hello World!hello-world (not reversible)

Best Practices for URL Encoding

Always Encode User Input

If your application accepts user input and places it into a URL (a search query, a form field, an API parameter), always encode it. Unencoded user input can break URL structure, cause server errors, or introduce security vulnerabilities like URL manipulation.

Use encodeURIComponent Over encodeURI for Query Parameters

JavaScript's encodeURIComponent() encodes more characters than encodeURI(), making it safer for query string values. Use encodeURI() only when encoding an entire URL where you want to preserve structural characters like / and ?.

Be Consistent with Encoding Standards

Most modern applications use UTF-8 encoding, which is the standard for the web. Ensure your server and client agree on the same encoding scheme to avoid double-encoding or decoding mismatches.

Do Not Encode Already-Encoded URLs

Double encoding happens when you encode a URL that is already encoded. If a value is already %26, encoding it again produces %2526 (the %25 is the encoded form of %). This is a common source of bugs — always check whether your data has already been encoded before processing it.

Validate URLs After Encoding

After encoding, test the resulting URL by pasting it into a browser or using an API client. Invalid percent sequences (such as %2 without the second hex digit) can cause errors. Our URL Encoder tool validates the output automatically.

FAQ

What does %20 mean in a URL?

%20 is the URL-encoded representation of a space character. Because spaces are not allowed in URLs, they are replaced with %20 (or + in some query string contexts under the application/x-www-form-urlencoded content type).

What does %2C mean in a URL?

%2C is the URL-encoded form of a comma (,). Commas are technically allowed in URLs but are often encoded to avoid ambiguity, especially in query parameters where commas might serve as delimiters in server-side parsing. If you searched for "2c url encoding", you were looking for %2C — the comma code.

What is the difference between URL encoding and HTML encoding?

URL encoding (percent encoding) converts characters for safe transmission in URLs — space becomes %20. HTML encoding converts characters for safe display in web pages — < represents < and & represents &. They serve different purposes: URL encoding for addresses and data transport, HTML encoding for content rendering.

When should I use + vs %20 for spaces?

In query string parameters, both + and %20 represent spaces under the application/x-www-form-urlencoded standard. In the path segment of a URL, only %20 is valid. Most modern URL encoders use %20 universally, which works in all contexts.

Can I put emojis in a URL?

Emojis are Unicode characters and must be URL-encoded. An emoji like 😀 becomes %F0%9F%98%80 — four percent-encoded bytes representing its UTF-8 encoding. Modern browsers handle this automatically, but if you are building URLs programmatically, always encode emoji characters using encodeURIComponent().

Need to encode or decode a URL right now? Use our free tool — no sign-up, no tracking.

Go to FreeTextUtils →