Back to articles
URL Encoding vs URL Decoding: When and How to Use It

URL Encoding vs URL Decoding: When and How to Use It

via Dev.to Webdev楊東霖

URLs are everywhere — in browser address bars, API requests, curl commands, email links, and log files. But URLs have strict rules about which characters they can contain. When your URL needs to include spaces, special characters, or non-ASCII text, URL encoding (also called percent-encoding) is the mechanism that makes it work. This guide explains URL encoding and decoding from first principles: why it exists, what the rules are, when you need to encode versus when you don't, and how to do it instantly in any language. What Is URL Encoding? URL encoding converts characters that are not safe for use in a URL into a format that is. It replaces unsafe characters with a % sign followed by two hexadecimal digits representing the character's ASCII code. Examples: Space → %20 @ → %40 / → %2F = → %3D & → %26 + → %2B A URL like: https://example.com/search?q=hello world&category=dev tools Becomes: https://example.com/search?q=hello%20world&category=dev%20tools Both URLs convey the same informat

Continue reading on Dev.to Webdev

Opens in a new tab

Read Full Article
2 views

Related Articles