Free URL string escaper tool to encode special characters instantly. Convert spaces, Unicode, and symbols to percent-encoded format. Perfect for APIs, web forms, and international URLs. Try now!
This URL string escaper helps you instantly encode URLs and escape special characters for safe web transmission. Simply paste your URL containing spaces, special characters, or Unicode symbols, and get a properly encoded URL that works across all browsers and servers. Essential for web developers, API integration, and anyone working with URLs containing non-ASCII characters.
URLs can only contain specific ASCII characters. When your URL includes spaces, foreign language characters (like é, ü, 中), or special symbols, they must be URL encoded (percent-encoded) to prevent errors. This tool automatically converts unsafe characters into %XX format, ensuring your URLs work reliably in:
URL encoding (also called percent-encoding) is the standard method for representing special characters in URLs. It converts characters into a format that can be transmitted over the Internet without corruption or misinterpretation. Each special character is replaced with % followed by two hexadecimal digits representing the character's code.
For example: A space ' ' becomes %20, and 'é' becomes %C3%A9.
According to the RFC 3986 specification, certain characters must be percent-encoded in URLs:
Reserved Characters (General delimiters):
: / ? # [ ] @Reserved Characters (Sub-delimiters):
! $ & ' ( ) * + , ; =Always Encode:
Safe Characters (Never Encoded):
A-Z, a-z0-9- . _ ~Identify Special Characters:
Parse the URL string and identify characters that are not unreserved ASCII characters (letters, digits, -, ., _, ~).
Convert to ASCII Code: For each special character, obtain its ASCII or Unicode code point.
Convert to UTF-8 Byte Sequence (if necessary): For non-ASCII characters, encode the character into one or more bytes using UTF-8 encoding.
Convert to Hexadecimal: Convert each byte to its two-digit hexadecimal equivalent.
Prefix with Percent Symbol:
Precede each hexadecimal byte with a % sign.
Character: ' ' (Space)
3220%20Character: 'é'
0xC3 0xA9%C3%A9Unicode Characters: Non-ASCII characters must be encoded in UTF-8 and then percent-encoded.
Already Encoded Percent Signs: Percent signs that are part of percent-encodings must not be re-encoded.
Reserved Characters in Query Strings: Certain characters have special meanings in query strings and should be encoded to prevent altering the structure.
URL decoding is the reverse process of URL encoding. It converts percent-encoded characters back to their original form, making the URL readable and interpretable by humans and systems.
Identify Percent-Encoding Sequences:
Locate all % symbols followed by two hexadecimal digits in the URL string.
Convert Hexadecimal to Bytes: Translate each hexadecimal value to its corresponding byte.
Decode UTF-8 Bytes (if necessary): For multi-byte sequences, combine the bytes and decode them using UTF-8 encoding to obtain the original character.
Replace Encoded Sequences: Substitute the percent-encoded sequences with the decoded characters.
Encoded: hello%20world
%20 translates to a space ' 'hello worldEncoded: J%C3%BCrgen
%C3%A4 translates to 'ü' in UTF-8JürgenURL decoding is essential when processing user input from URLs, reading query parameters, or interpreting data received from web requests. It ensures that the information extracted from a URL is in its proper, intended form.
"shoes & bags" → shoes%20%26%20bags| Method | Use Case | Example |
|---|---|---|
| URL Encoding | Query strings, path parameters | hello world → hello%20world |
| Base64 Encoding | Binary data, authentication tokens | hello → aGVsbG8= |
| HTML Entity Encoding | Displaying special chars in HTML | <script> → <script> |
| JSON Encoding | API payloads, data structures | Special chars in JSON strings |
URL encoding was introduced with the early specifications of the URL and URI (Uniform Resource Identifier) standards in the 1990s. The need for a consistent way to encode special characters arose from the diverse systems and character sets used worldwide.
Key milestones include:
RFC 1738 (1994): Defined URLs and introduced percent-encoding.
RFC 3986 (2005): Updated the URI syntax, refining the rules for encoding.
Over time, URL encoding has become integral to web technologies, ensuring reliable communication across different systems and platforms.
Here are examples of how to perform URL encoding in various programming languages:
1' Excel VBA Example
2Function URLEncode(ByVal Text As String) As String
3 Dim i As Integer
4 Dim CharCode As Integer
5 Dim Char As String
6 Dim EncodedText As String
7
8 For i = 1 To Len(Text)
9 Char = Mid(Text, i, 1)
10 CharCode = AscW(Char)
11 Select Case CharCode
12 Case 48 To 57, 65 To 90, 97 To 122, 45, 46, 95, 126 ' 0-9, A-Z, a-z, -, ., _, ~
13 EncodedText = EncodedText & Char
14 Case Else
15 If CharCode < 0 Then
16 ' Handle Unicode characters
17 EncodedText = EncodedText & "%" & Hex(65536 + CharCode)
18 Else
19 EncodedText = EncodedText & "%" & Right("0" & Hex(CharCode), 2)
20 End If
21 End Select
22 Next i
23 URLEncode = EncodedText
24End Function
25
26' Usage:
27' =URLEncode("https://example.com/?name=Jürgen")
281% MATLAB Example
2function encodedURL = urlEncode(url)
3 import java.net.URLEncoder
4 encodedURL = char(URLEncoder.encode(url, 'UTF-8'));
5end
6
7% Usage:
8% encodedURL = urlEncode('https://example.com/?name=Jürgen');
91## Ruby Example
2require 'uri'
3
4url = 'https://example.com/path?query=hello world&name=Jürgen'
5encoded_url = URI::DEFAULT_PARSER.escape(url)
6puts encoded_url
7## Output: https://example.com/path?query=hello%20world&name=J%C3%BCrgen
81// Rust Example
2use url::form_urlencoded;
3
4fn main() {
5 let url = "https://example.com/path?query=hello world&name=Jürgen";
6 let encoded_url = percent_encode(url);
7 println!("{}", encoded_url);
8 // Output: https://example.com/path%3Fquery%3Dhello%20world%26name%3DJ%C3%BCrgen
9}
10
11fn percent_encode(input: &str) -> String {
12 use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
13 utf8_percent_encode(input, NON_ALPHANUMERIC).to_string()
14}
151## Python Example
2import urllib.parse
3
4url = 'https://example.com/path?query=hello world&name=Jürgen'
5encoded_url = urllib.parse.quote(url, safe=':/?&=')
6print(encoded_url)
7## Output: https://example.com/path?query=hello%20world&name=J%C3%BCrgen
81// JavaScript Example
2const url = 'https://example.com/path?query=hello world&name=Jürgen';
3const encodedURL = encodeURI(url);
4console.log(encodedURL);
5// Output: https://example.com/path?query=hello%20world&name=J%C3%BCrgen
61// Java Example
2import java.net.URLEncoder;
3import java.nio.charset.StandardCharsets;
4
5public class URLEncodeExample {
6 public static void main(String[] args) throws Exception {
7 String url = "https://example.com/path?query=hello world&name=Jürgen";
8 String encodedURL = URLEncoder.encode(url, StandardCharsets.UTF_8.toString());
9 // Replace "+" with "%20" for spaces
10 encodedURL = encodedURL.replace("+", "%20");
11 System.out.println(encodedURL);
12 // Output: https%3A%2F%2Fexample.com%2Fpath%3Fquery%3Dhello%20world%26name%3DJ%C3%BCrgen
13 }
14}
151// C# Example
2using System;
3using System.Net;
4
5class Program
6{
7 static void Main()
8 {
9 string url = "https://example.com/path?query=hello world&name=Jürgen";
10 string encodedURL = Uri.EscapeUriString(url);
11 Console.WriteLine(encodedURL);
12 // Output: https://example.com/path?query=hello%20world&name=J%C3%BCrgen
13 }
14}
151<?php
2// PHP Example
3$url = 'https://example.com/path?query=hello world&name=Jürgen';
4$encodedURL = urlencode($url);
5echo $encodedURL;
6// Output: https%3A%2F%2Fexample.com%2Fpath%3Fquery%3Dhello+world%26name%3DJ%C3%BCrgen
7?>
81// Go Example
2package main
3
4import (
5 "fmt"
6 "net/url"
7)
8
9func main() {
10 urlStr := "https://example.com/path?query=hello world&name=Jürgen"
11 encodedURL := url.QueryEscape(urlStr)
12 fmt.Println(encodedURL)
13 // Output: https%3A%2F%2Fexample.com%2Fpath%3Fquery%3Dhello+world%26name%3DJ%25C3%25BCrgen
14}
151// Swift Example
2import Foundation
3
4let url = "https://example.com/path?query=hello world&name=Jürgen"
5if let encodedURL = url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) {
6 print(encodedURL)
7 // Output: https://example.com/path?query=hello%20world&name=J%C3%BCrgen
8}
91## R Example
2url <- "https://example.com/path?query=hello world&name=Jürgen"
3encodedURL <- URLencode(url, reserved = TRUE)
4print(encodedURL)
5## Output: https://example.com/path?query=hello%20world&name=J%C3%BCrgen
6Note: The output may vary slightly based on how each language handles reserved characters and spaces (e.g., encoding spaces as %20 or +).
Proper URL encoding and decoding are critical for security:
Prevent Injection Attacks: Encoding user input helps prevent malicious code from being executed, mitigating risks like cross-site scripting (XSS) and SQL injection.
Data Integrity: Ensures that data is transmitted without alteration or corruption.
Compliance with Standards: Adhering to encoding standards avoids interoperability issues between systems.
Double Encoding Prevention: Avoid encoding already-encoded URLs, which can cause errors in URL parsing.
URL encoding and URL escaping are the same thing. Both terms refer to percent-encoding, where special characters are converted to % followed by hexadecimal digits. The terms are used interchangeably in web development.
Only encode the query string values and path parameters, not the entire URL structure. Never encode the protocol (https://) or domain name. For example, encode https://example.com/?name=John Doe as https://example.com/?name=John%20Doe.
Both represent spaces, but %20 is the standard percent-encoding for spaces in URLs. The + character is specific to application/x-www-form-urlencoded format (HTML forms). Modern web development prefers %20 for consistency.
Use encodeURIComponent() for query parameters and encodeURI() for full URLs. Example: encodeURIComponent('hello world') returns 'hello%20world'. Avoid the deprecated escape() function.
Only decode once. Double-decoding can cause security vulnerabilities or incorrect results. Always check if a URL is already decoded before applying URL decoding again.
Characters like / and : are reserved characters with special meaning in URL structure. They're only encoded when used as literal data (e.g., in query parameters), not when they're part of the URL syntax.
Unicode characters are automatically converted to UTF-8 bytes, then percent-encoded. For example, '中' becomes %E4%B8%AD (three bytes in UTF-8). This tool handles Unicode encoding automatically.
No. URL encoding converts special characters to %XX format for URL compatibility. Base64 encoding converts binary data to alphanumeric strings and is used for different purposes like encoding images or authentication tokens.
URL encoding is essential for secure web development and reliable data transmission. Whether you're building APIs, handling international content, or ensuring data integrity, properly encoded URLs prevent errors and security vulnerabilities.
Use this free URL string escaper tool to:
Try the tool now by pasting your URL in the field above. Get your percent-encoded URL instantly and ensure your web applications handle URLs correctly every time.
Discover more tools that might be useful for your workflow