Encode and decode URLs for safe web transmission.
Welcome to the ultimate resource for URL encoding and decoding. This page is built to help developers, marketers, SEO specialists, and anyone working with links understand exactly how URL encoding works, why it matters, and how to use it correctly in real-world web projects.
URLs are the backbone of the web. But when URLs contain spaces, punctuation, or special characters, they can become broken, unreadable, or unsafe. That is why URL encoding exists: to transform those characters into a standardized format so links remain functional, secure, and compatible across browsers and servers.
This article goes far beyond the basics. You will learn the technical details of percent-encoding, how browsers and servers interpret encoded URLs, the SEO and security implications, and the most common mistakes to avoid. You will also find real examples, tool recommendations, and a full best-practices checklist for web professionals.
URL encoding, also called percent-encoding, converts characters that are not safe for URLs into a format that can be transmitted over the internet reliably. The process replaces unsafe characters with a percent sign (%) followed by two hexadecimal digits that represent the character's ASCII code.
For example:
Space becomes %20# becomes %23& becomes %26? becomes %3FThis encoding ensures that the URL parser treats the data as part of the link rather than as special syntax.
At its core, URL encoding serves two important goals:
When you use our tool to encode a URL, it makes the link safe for use in browsers, APIs, forms, and server requests.
URL encoding matters for several reasons, including:
This is why URL encoding is required when sending data through query strings, saving URLs into databases, generating email links, or creating deep links for mobile apps.
The URL specification divides characters into two categories: reserved and unreserved.
These characters are safe to use in URLs without encoding:
A-Za-z0-9-_.~These characters are considered safe and usually do not require percent-encoding.
Reserved characters have special meaning in URLs. They include:
: - scheme separator/ - path separator? - start of query string# - start of fragment[ ] - IPv6 literals@ - user info separator!, $, &, ', (, ), *, +, ,, ;, =If you want any of these characters to be treated as data rather than part of URL syntax, you must percent-encode them.
Characters that almost always need encoding include:
→ %20# → %23% → %25& → %26+ → %2B? → %3F= → %3D/ → %2FURL encoding is used in many parts of modern web development and digital marketing:
https://example.com/search?q=hello%20world./users/John%20Doe.For example, a search URL that contains a question mark or ampersand must encode those characters so the server can separate them correctly. When debugging API issues, use a JSON formatter to validate the structure of your encoded payloads.
A query string is the portion of a URL that follows the question mark ?. Each parameter inside the query string is usually separated by an ampersand (&).
Example before encoding:
https://ourtoolkit.online/search?query=url encoder decoder&page=1
Example after encoding:
https://ourtoolkit.online/search?query=url%20encoder%20decoder&page=1
Encoding the space as %20 makes the query string valid.
When user-generated values appear in the URL path, encoding is required to keep the path valid. For example, a username with spaces or symbols should be encoded.
Example before encoding:
https://ourtoolkit.online/profile/John Doe
Example after encoding:
https://ourtoolkit.online/profile/John%20Doe
Note that this is different from query string encoding because the entire value is part of the path.
Fragment identifiers are the part of the URL after #. If the fragment includes spaces or special characters, it should be encoded too.
Example:
https://ourtoolkit.online/docs#section-1%20overview
In many cases, browsers also handle fragments automatically, but encoding ensures predictable results.
URL decoding is the reverse process of encoding. It takes a percent-encoded string and converts it back to the original characters.
For example:
%20 → %23 → #%26 → &%2F → /Decoding is essential when reading incoming URLs, parsing query strings, or displaying user-friendly links.
Decode incoming URLs when you need to:
However, avoid decoding URLs too early if they will be passed through additional URL handling logic again.
Many web servers and frameworks automatically decode URL-encoded values before handing them to your application. That means your route handlers may already receive decoded strings, while the raw request contains encoded data.
This is why it is important to know the difference between the encoded URL seen in the browser and the decoded value used in your code.
Practical examples are the best way to understand URL encoding. The examples below show common encoding scenarios.
Original query:
https://ourtoolkit.online/search?q=URL encoder decoder&sort=popular
Encoded query:
https://ourtoolkit.online/search?q=URL%20encoder%20decoder&sort=popular
This ensures that the space inside the query parameter is safely transmitted.
Original file path:
https://ourtoolkit.online/downloads/My File (Final).zip
Encoded file path:
https://ourtoolkit.online/downloads/My%20File%20%28Final%29.zip
Encoding parentheses and spaces prevents server path issues and broken downloads.
Original URL:
https://ourtoolkit.online/book?title=The Great Gatsby&author=F. Scott Fitzgerald&year=1925
Encoded URL:
https://ourtoolkit.online/book?title=The%20Great%20Gatsby&author=F.%20Scott%20Fitzgerald&year=1925
The tool will also encode the dot and period only if they appear in a parameter value that could be misread in context.
Original URL:
https://ourtoolkit.online/path?message=Hello & welcome! #2026
Encoded URL:
https://ourtoolkit.online/path?message=Hello%20%26%20welcome%21%20%232026
Special characters like &, exclamation marks, and hash signs must be encoded inside a query string.
Using URL decoding, encoded values are converted back into human-readable form.
Encoded URL:
https://ourtoolkit.online/search?q=URL%20encoder%20decoder
Decoded value:
URL encoder decoder
Decoding makes it easy to extract the exact search phrase from a query parameter.
Encoded form payload:
name=Jane%20Doe&email=jane.doe%40example.com&newsletter=yes
Decoded values:
name=Jane Doe
email=jane.doe@example.com
newsletter=yes
Many form processors decode values automatically, but this tool helps if you want to verify the result manually.
Encoded path:
https://ourtoolkit.online/profile/John%20Doe
Decoded segment:
John Doe
This is especially useful for route matching and user profile URLs.
Even experienced developers can make mistakes with URL encoding. These common errors can cause broken links or unexpected behavior.
Spaces are one of the most frequent culprits. If you leave a space unencoded inside a URL, browsers may convert it to a plus sign or split the URL into multiple segments.
Fix: Always encode spaces as %20 in URLs, except when using application/x-www-form-urlencoded in form data where plus signs may be used.
A common mistake is encoding an entire URL including the scheme and hostname. This can create invalid links.
Fix: Encode only the parts that need it — path segments, query parameters, or fragments — not the protocol, host, or port.
HTML forms submitted with application/x-www-form-urlencoded encode spaces as plus signs (+), not %20. This difference matters when decoding values.
Fix: Use the correct decoding function for form-encoded data, or encode query strings with %20 for universal compatibility.
Double encoding occurs when a value is encoded twice, turning %20 into %2520. The result is unreadable and may not decode correctly.
Fix: Encode only once, and decode before encoding again if necessary.
Clean, valid URLs are important for search engine ranking as well as user experience. Improper URL encoding can harm SEO in several ways:
Using this tool helps you create SEO-friendly URLs by preserving meaningful text while ensuring the link remains valid.
For example, /shop/summer-sale is better than /shop/summer%20sale, but when dynamic values are required, encoding keeps the URL safe.
URL encoding also plays a role in web security. By encoding untrusted input before including it in a URL, you reduce the risk of injection attacks and request smuggling.
Important security rules:
Proper URL encoding is a security best practice that complements input validation and output escaping. Always validate and encode sensitive data before transmission.
Different browsers may behave differently when they encounter unencoded or partially encoded URLs. This is why you should not rely on the browser to fix broken links automatically. For consistency, you can use a URL shortener to normalize link formats across browsers.
Examples of browser behavior:
%20 or +.To ensure consistent behavior across browsers, always encode URLs before using them in navigation, redirection, AJAX calls, or embedded links. Test your encoded URLs across multiple browsers to catch inconsistencies before deployment.
Most programming languages and frameworks include built-in functions for URL encoding and decoding. When you automate encoding, always use well-tested library calls rather than manual string replacements.
The right function depends on the context: full URLs, query string values, or path segments. Use the correct helper so reserved characters and Unicode values are encoded properly.
In JavaScript, there are two common encoding methods:
encodeURI() - encodes a complete URI but leaves URI punctuation intact.encodeURIComponent() - encodes individual components, including characters like &, =, and ?.Use encodeURIComponent() for query values and path segments, and use encodeURI() only when the full URL already has valid syntax.
const base = 'https://ourtoolkit.online/search';
const query = 'URL encoder & decoder';
const url = `${base}?q=${encodeURIComponent(query)}`;
console.log(url);
// https://ourtoolkit.online/search?q=URL%20encoder%20%26%20decoder
To decode a value in JavaScript:
const decoded = decodeURIComponent('URL%20encoder%20%26%20decoder');
console.log(decoded); // URL encoder & decoder
Python's standard library provides tools under urllib.parse. When working with APIs that return JSON responses with encoded URLs, Python's URL tools help normalize the data:
from urllib.parse import quote, unquote
value = 'hello world & example'
encoded = quote(value)
print(encoded) # hello%20world%20%26%20example
decoded = unquote(encoded)
print(decoded) # hello world & example
If your application needs to encode query strings, use quote_plus() and unquote_plus() for form-style encoding where spaces become plus signs.
PHP also includes simple URL encoding helpers:
$value = 'Hello world & test';
$encoded = urlencode($value);
echo $encoded; // Hello+world+%26+test
$decoded = urldecode($encoded);
echo $decoded; // Hello world & test
Use urlencode() for query data and rawurlencode() for path segments if you want spaces as %20 instead of plus signs.
Java provides encoding utilities in java.net. When building RESTful APIs that return JSON data with encoded parameters, proper encoding is essential:
import java.net.URLEncoder;
import java.net.URLDecoder;
String value = "Spring & Summer";
String encoded = URLEncoder.encode(value, "UTF-8");
System.out.println(encoded); // Spring+%26+Summer
String decoded = URLDecoder.decode(encoded, "UTF-8");
System.out.println(decoded); // Spring & Summer
Java encodes spaces as plus signs by default. This is fine for many forms and query strings but be careful when working with path segments.
Ruby makes encoding easy with the URI module:
require 'uri'
value = 'Winter / Spring'
encoded = URI.encode_www_form_component(value)
puts encoded # Winter+%2F+Spring
decoded = URI.decode_www_form_component(encoded)
puts decoded # Winter / Spring
In C#, use System.Web.HttpUtility or System.Net.WebUtility:
using System.Web;
string value = "Test & Encode";
string encoded = HttpUtility.UrlEncode(value);
Console.WriteLine(encoded); // Test+%26+Encode
string decoded = HttpUtility.UrlDecode(encoded);
Console.WriteLine(decoded); // Test & Encode
If you are using .NET Core, prefer WebUtility.UrlEncode and WebUtility.UrlDecode.
Go provides encoding tools inside net/url. For API development, combine URL encoding with JSON validation tools to ensure data integrity:
package main
import (
"fmt"
"net/url"
)
func main() {
value := "name=John Doe & age=30"
encoded := url.QueryEscape(value)
fmt.Println(encoded) // name%3DJohn+Doe+%26+age%3D30
decoded, _ := url.QueryUnescape(encoded)
fmt.Println(decoded) // name=John Doe & age=30
}
Encoding functions are not interchangeable. Use:
application/x-www-form-urlencoded payloads.Incorrect use of encoding functions is a frequent source of errors when building dynamic URLs.
Modern URLs often include Unicode characters, such as accented letters or emojis. Percent-encoding works with UTF-8, meaning the characters are first encoded in UTF-8 and then percent-encoded byte-by-byte.
Example:
const encoded = encodeURIComponent('café ☕');
console.log(encoded); // caf%C3%A9%20%E2%98%95
const decoded = decodeURIComponent(encoded);
console.log(decoded); // café ☕
Using Unicode-aware encoding ensures that international content is preserved and can be read by browsers everywhere.
It is important to distinguish URL encoding from character encoding. Character encoding (such as UTF-8) determines how text is represented as bytes. URL encoding represents those bytes inside a URL using percent escapes.
In short:
For web applications, UTF-8 is the standard character encoding, and URL percent-encoding is what makes those bytes safe for URLs.
If a URL is not working, these troubleshooting steps help identify the problem quickly:
For example, if https://example.com/search?q=hello world fails, the issue is almost always the unencoded space. The fix is to encode it as https://example.com/search?q=hello%20world.
Browser developer tools are useful when working with encoded URLs:
These techniques help you catch encoding issues before they impact users.
APIs often require precise encoding rules. When building or consuming APIs, encode the query parameters and ensure that the endpoint expects the same encoding format. Use a JSON formatter to validate your API payloads and responses.
Example API request:
GET https://api.example.com/v1/items?search=phone%20case&sort=price
If the API is built with frameworks like Express, Django, Flask, or Spring, the server usually decodes the query string automatically, letting your application use the decoded value. Always validate your JSON API responses to ensure encoded URLs are handled correctly.
However, if the API uses path parameters, you may need to encode the value manually in the URL.
Email links and social media share URLs often include multiple encoded parameters. Correct encoding prevents the shared link from breaking and preserves the intended message. For frequently shared links, consider using a URL shortener to reduce encoding complexity and improve tracking.
Example email link:
mailto:friend@example.com?subject=Check%20this%20out&body=Visit%20https%3A%2F%2Fourtoolkit.online%2Furl-encoder-decoder
Example social share link:
https://twitter.com/intent/tweet?text=Try%20this%20URL%20tool%20from%20OurToolkit%21&url=https%3A%2F%2Fourtoolkit.online%2Furl-encoder-decoder
Encoding these links correctly ensures the sharing experience works across email clients and social platforms.
Analytics platforms like Google Analytics rely on encoded UTM tags. If you include characters such as spaces or ampersands without encoding, tracking may fail or the values may be split incorrectly. When setting up analytics, generate URLs with URL shortening tools to simplify campaign tracking.
Example:
https://ourtoolkit.online/?utm_source=blog&utm_medium=email&utm_campaign=Summer%20Launch
Always encode UTM values when building campaign URLs to make sure your analytics data remains accurate.
Canonical URLs tell search engines which version of a page is the authoritative one. When your site can be accessed with both encoded and decoded versions of a link, use canonical tags to avoid duplicate content. Configure your robots.txt file to guide crawlers toward canonical versions and improve your site's SEO authority.
For example, if your page can be reached as:
/search?query=our toolkit/search?query=our%20toolkitUse a canonical URL such as https://ourtoolkit.online/search?query=our%20toolkit to signal the preferred version to search engines.
Our URL Encoder & Decoder tool is designed for fast, accurate conversion of URLs and query strings.
This tool is especially useful when:
Follow these best practices to keep your links safe and SEO-friendly:
encodeURIComponent() for query values in JavaScript.encodeURI() when encoding an entire URI that contains already-encoded parts.For example, if your site uses user names or product names in URLs, encode those values before adding them to the page URL.
%20 or plus signs when required?&, #, and = encoded?In REST APIs, path parameters often contain user-generated content. Encoding these segments ensures the API routes match correctly. When your API returns JSON responses with encoded URLs, ensure proper decoding on the client side.
Example:
GET /api/users/John%20Doe
The server can decode John%20Doe and return the correct user profile. Use our JSON formatter to validate API responses containing encoded data.
OAuth redirects often require encoded query parameters, especially when the callback URL includes its own query string. Encoding prevents the redirect from being misinterpreted. When working with API authentication, ensure your JSON payloads are properly formatted and URLs are correctly encoded.
Example:
https://auth.example.com/authorize?redirect_uri=https%3A%2F%2Fapp.example.com%2Fcallback%3Fsource%3Demail
In this example, the inner callback URL is encoded so the OAuth provider can handle it safely. For API data validation, use our Base64 encoder when encoding authentication tokens.
Marketing tags like UTM parameters often include special characters. Encoding ensures those tags are correctly recognized by analytics systems. When tracking links with special characters or QR codes, proper encoding prevents data loss.
Example:
https://ourtoolkit.online/?utm_source=summer%20email&utm_medium=email&utm_campaign=Spring%20Launch
To validate your analytics parameters, use JSON formatters to verify API payloads that contain your encoded tracking data.
To support your workflow, use these related pages on our site:
These tools help you manage structured data, optimize links, reduce duplicate content, and build reliable web experiences. Use them together to create a comprehensive web development and SEO workflow.
URL encoding converts special characters into percent-encoded values so they can be safely included in URLs. URL decoding reverses that process, restoring the original characters. Similar principles apply to Base64 encoding for different data types.
No. You should encode only the parts of the URL that contain unsafe or reserved characters, such as query values, path parameters, or fragment identifiers. Do not encode the scheme, host, or port. For managing multiple page versions, use robots.txt rules to guide search engines.
+ the same as %20?Not exactly. In HTML form encoding, the plus sign (+) often represents a space. In general URL percent-encoding, a space is represented as %20. Use the correct encoding method for your context. When debugging form data, JSON formatters help validate API payloads.
Yes, search engines can index encoded URLs. However, make sure your site uses canonical URLs and avoids multiple encoded versions of the same page to prevent duplicate content issues. Define crawl rules in robots.txt to prevent indexing of duplicate encoded versions.
If the URL contains percent signs followed by two hexadecimal digits, it is likely already encoded. Use a decoding tool to confirm and avoid double-encoding.
Check that you have encoded only the correct parts, and ensure the link is not being re-encoded or decoded incorrectly by another layer of software. Also verify that the server has the right route configuration for encoded path values.
URL encoding is a simple concept with powerful implications. It keeps your links safe, readable, and compatible across browsers, servers, APIs, and search engines.
Our URL Encoder & Decoder tool is designed to make this process fast and accurate. Whether you are building a website with proper SEO rules, working with APIs and JSON payloads, preparing QR codes and marketing links, or debugging URLs, this tool gives you the confidence to encode and decode values correctly.
Remember these key points:
Use this page as your long-form reference, and come back whenever you need a clear, dependable URL encoding solution. Explore our Base64 encoder for encoding binary data, or try our Markdown converter for building content with clean, encoded links.