What Is URL Encoding?
URLs can only contain a limited set of safe ASCII characters. Spaces, special symbols, non-ASCII characters, and characters with reserved meaning in URLs (like &, =, ?, #) must be encoded before they can be used safely in a URL. URL encoding (also called percent encoding) converts unsafe characters into a percent sign followed by two hexadecimal digits representing the character code.
For example: a space becomes %20, an ampersand becomes %26, and a forward slash in a filename becomes %2F.
Why URL Encoding Matters for Developers
URL encoding issues cause some of the most confusing bugs in web development. A search query passed as a URL parameter that contains special characters, an image filename with spaces that breaks a src attribute, a redirect URL with an ampersand that gets misinterpreted as a parameter separator - all of these are URL encoding bugs. Understanding encoding lets you debug them quickly and prevent them from happening in the first place.
Characters That Must Be Encoded in URLs
- Space → %20 (or + in form submissions)
- & (ampersand) → %26
- = (equals) → %3D
- ? (question mark) → %3F
- # (hash) → %23
- / (forward slash) → %2F (when in a path segment value)
- + (plus) → %2B
- @ (at sign) → %40
URL Encoding vs HTML Encoding
These are different things that beginners sometimes confuse. URL encoding uses percent signs (%20 for space). HTML entity encoding uses ampersand notation (& for &, < for <). Use URL encoding for query parameters and paths. Use HTML entity encoding for displaying content inside HTML documents. Use both when a URL appears inside an HTML attribute.
How to Encode/Decode URLs Free with Sejda
- Go to the tool - Visit /tools/url-encode.
- Choose Encode or Decode
- Paste your text or URL
- Click Process - Instant result
- Copy the output
Common Real-World URL Encoding Scenarios
- Search query parameters - q=hello%20world encodes the space in "hello world"
- Redirect URLs as parameters - redirect=%2Fdashboard%3Fid%3D42 encodes the redirect path
- Filenames with spaces - my%20file.pdf encodes spaces in a file download link
- International characters - café becomes caf%C3%A9 in UTF-8 URL encoding
- API endpoint parameters - Dates, emails, and addresses in query strings all need encoding
Encoding in Different Programming Languages
- JavaScript - encodeURIComponent("hello world") → "hello%20world"
- Python - urllib.parse.quote("hello world") → "hello%20world"
- PHP - urlencode("hello world") → "hello+20world" (note: + not %20)
- Java - URLEncoder.encode("hello world", "UTF-8")
Frequently Asked Questions
What is the difference between %20 and + for spaces?
%20 is the universal percent encoding for space, valid in all URL contexts. The + sign represents a space only in form-encoded data (application/x-www-form-urlencoded), not in URL paths. To be safe, use %20 everywhere.
Can I decode a URL that contains foreign characters?
Yes. International characters are encoded as multi-byte UTF-8 sequences in percent encoding. Sejda decodes all standard UTF-8 percent-encoded sequences.
Why does my URL look correct but still break?
Double encoding is a common issue - encoding a string that was already encoded, resulting in %2520 (the % itself gets encoded to %25). Always encode from the raw unencoded value, not from an already-encoded string.
Free Developer Tools
- URL Encoder/Decoder - Encode and decode URLs instantly. Free.
- Base64 Encoder - Encode binary data for web use.
- JSON Formatter - Format and validate JSON responses.
Related Articles
- How to Use Base64 Encoding and Decoding
- How to Format JSON Online Free
- Best Free Developer Tools Online
Conclusion
URL encoding is one of those foundational web concepts that trips up developers of all experience levels. Understanding when and how to encode, and having a fast tool to encode and decode on demand, saves hours of debugging. Sejda's URL encoder is free, instant, and handles all edge cases correctly. Keep it bookmarked.