The Complete Guide to URL Encoding
Learn everything about URL encoding: what it is, why it matters, how percent-encoding works, and best practices for handling special characters in URLs across different programming languages.
Tips, guides, and best practices for URL encoding and web development.
Learn everything about URL encoding: what it is, why it matters, how percent-encoding works, and best practices for handling special characters in URLs across different programming languages.
A detailed comparison of JavaScript's encodeURIComponent() and encodeURI() functions. Understand the critical differences and avoid common pitfalls when encoding URLs in your web applications.
Troubleshoot and fix the common "URIError: URI malformed" error in JavaScript. Learn the causes, prevention strategies, and how to build robust URL handling in your applications.
A comprehensive reference for URL encoding special characters including spaces, ampersands, question marks, unicode characters, and more. Includes encoding tables and language-specific examples.
Master URL encoding in REST API development. Learn how to properly encode query parameters, path segments, and request bodies to build reliable and interoperable APIs.
encodeURI encodes a full URL preserving structural characters like /, ?, and #. encodeURIComponent encodes a single URI component, encoding all special characters including /, ?, and &. Use encodeURIComponent for query parameter values and encodeURI for complete URLs.
URL encoding (percent-encoding) converts special characters in URLs to %XX format per RFC 3986. Base64 encoding converts binary data to a text string using 64 ASCII characters per RFC 4648. They serve different purposes and are not interchangeable.
Complete reference table of URL encoded characters. Covers all ASCII printable characters (32-126), common Unicode characters, and their percent-encoded equivalents as defined by RFC 3986.
Python URL encoding uses urllib.parse.quote() for percent-encoding strings and urllib.parse.urlencode() for encoding dictionaries into query strings. This guide covers quote(), unquote(), urlencode(), and parse_qs() with practical examples.
Percent encoding is a mechanism defined in RFC 3986 for encoding special characters in URIs by replacing them with a percent sign (%) followed by two hexadecimal digits. It ensures URLs contain only valid ASCII characters that can be transmitted safely over the internet.
%20 is the standard RFC 3986 percent-encoding for a space character and should be used in URL paths and most contexts. The + sign represents a space only in application/x-www-form-urlencoded format, used in HTML form submissions and some query strings.
JavaScript provides decodeURIComponent() to decode individual URI components and decodeURI() to decode complete URIs. Use try-catch to handle malformed URIs. The URL and URLSearchParams APIs provide safer alternatives for parsing URLs.
REST API query parameters must be percent-encoded per RFC 3986 to safely include special characters like &, =, spaces, and Unicode. Use encodeURIComponent() in JavaScript, urllib.parse.quote() in Python, or URLEncoder.encode() in Java.
HTML entity encoding converts characters like <, >, &, and " to HTML entities (<, >, &, ") for safe display in web pages. URL encoding converts characters to %XX format for safe transmission in URLs. They protect against different types of attacks and are used in different contexts.
The ERR_INVALID_URL error in Node.js occurs when the URL constructor or url.parse() receives a string that is not a valid URL. Common causes include missing protocol, unencoded special characters, and malformed percent-encoding. Fix it by validating input and encoding special characters before parsing.