What Is URL Encoding
URL Encoding (also called Percent-Encoding) converts special characters into % followed by two hexadecimal digits, which is exactly what an online url encoder does for you. For example, a space becomes %20, and the Chinese character "你" becomes %E4%BD%A0.
URL encoding ensures URLs contain only safe ASCII characters, preventing special characters from breaking URL structure.
Why You Need URL Encoding
- Safe transmission: Special characters in URLs (
?,&,=) have reserved meanings and must be encoded - Chinese/non-ASCII support: Browser address bars don't directly support non-ASCII characters
- Form submission: HTML forms using
application/x-www-form-urlencodedrequire encoding - API calls: Query parameter values must be encoded to avoid ambiguity
Common URL Encoding Reference
| Character | Encoding | Notes |
|-----------|----------|-------|
| Space | %20 or + | Most common encoding |
| & | %26 | Query parameter separator |
| = | %3D | Key-value separator |
| ? | %3F | Query string start |
| / | %2F | Path separator |
| # | %23 | Fragment identifier |
| % | %25 | The encoding character itself |
| + | %2B | Plus sign (+ represents space in query strings) |
Two Encoding Scenarios
1. URL Path Encoding
Encodes the path portion while preserving / and path structure:
Original: https://example.com/docs/getting-started.html
Encoded: https://example.com/%E6%96%87%E6%A1%A3/%E5%85%A5%E9%97%A8%E6%8C%87%E5%8D%97.html
2. Query Parameter Encoding
Encodes query parameter values while preserving ?, &, = structure (a url params parser can help you inspect the result):
Original: https://example.com/search?q=hello world&lang=zh-CN
Encoded: https://example.com/search?q=hello%20world&lang=zh-CN
How to Use an Online URL Encoder/Decoder
Using DevToolkit Pro's URL Encoder:
Encode
- Enter the original text or URL
- Choose encoding mode (URL encoding / component encoding)
- Click Encode
- Copy the encoded result
Decode
- Enter the encoded text
- Click Decode
- The original text appears in the output area
Encoding Mode Differences
| Mode | Description | Use Case |
|------|-------------|----------|
| encodeURIComponent | Encodes all special chars including / | Encoding query parameter values |
| encodeURI | Preserves /, :, @ and other URL structure | Encoding complete URLs |
Encoding Examples
const url = 'https://example.com/path?q=hello world';
// encodeURIComponent (encodes parameter values)
// Result: https%3A%2F%2Fexample.com%2Fpath%3Fq%3Dhello%20world
// encodeURI (encodes full URL)
// Result: https://example.com/path?q=hello%20world
URL Encoding in Web Development
HTML Forms
<form action="/search" method="GET">
<input name="q" value="hello world">
<!-- Submits as: /search?q=hello+world -->
</form>
JavaScript fetch API
// Auto-encodes query parameters
const params = new URLSearchParams({
q: 'hello world',
lang: 'zh-CN'
});
fetch(`/search?${params}`);
Backend Reception
// Node.js Express
app.get('/search', (req, res) => {
const query = req.query.q; // Auto-decoded to "hello world"
});
FAQ
What's the Difference Between URL Encoding and Base64?
URL encoding preserves URL structure, encoding only special and non-ASCII characters. Base64 is a general binary-to-text encoding that produces URL-unfriendly characters (+, /, =). Use URL encoding for URL contexts.
Why Is a Space Sometimes %20 and Sometimes +?
In URL paths, spaces encode as %20. In query strings using application/x-www-form-urlencoded format, spaces encode as +. The two formats are used in different contexts.
Can an Encoded URL Still Be Accessed?
Yes. Browsers and servers support URL encoding and automatically decode it. An encoded URL is fully valid.
This article is brought to you by DevToolkit Pro. More developer tools at the homepage.
relatedTools
Related Articles
Best Online JWT Decoder Tools (2026)
Comparing leading online JWT decoder tools across signature verification, privacy protection, and feature completeness. DevToolkit Pro stands out with local decoding and HS256 signature verification.
Best Online Base64 Encoder and Decoder Tools (2026)
Comparing leading online Base64 encoder and decoder tools across Unicode support, privacy protection, and ease of use. DevToolkit Pro stands out with local processing and Unicode-safe encoding.
Online Base64 to Image Converter: Decode Base64 Strings to Image Files
Learn how to convert Base64 encoded strings back to image files. Understand Base64 decoding principles, common image MIME types, and real-world Web development use cases.