XhCode Online Converter Tools
Copy encrypted URL

URL online encoding and decoding tool

1,This function implements Url: UrlEncode encoding and UrlDecode decoding
2,After encoding Url, some special characters and Chinese characters can be turned into Encode encoding format
URL Encoding and Decoding

URL encoding (also known as percent encoding) is a way of encoding special characters in URLs to ensure they are transmitted correctly over the web. URLs can only contain certain characters (letters, digits, and a few special characters like -, _, . and ~). Any other character (such as spaces, punctuation, or non-ASCII characters) needs to be encoded into a format that can be safely transmitted over HTTP.

What is URL Encoding?
URL encoding converts characters into a format that can be sent over the internet. It uses a combination of characters and percent signs (%) to represent non-URL-safe characters.

For example:

A space is encoded as %20.
The ampersand (&) is encoded as %26.
The equal sign (=) is encoded as %3D.
Why is URL Encoding Used?
URL encoding is used to:

Ensure that special characters (e.g., spaces, slashes) do not interfere with the structure of the URL.
Represent non-ASCII characters (e.g., Chinese, accented characters) in a way that can be safely transmitted over the web.
Encode data sent via HTTP GET requests (e.g., form submission).
URL Decoding
URL decoding is the reverse of URL encoding. It converts percent-encoded characters back to their original form.

For example:

%20 becomes a space.
%26 becomes the ampersand (&).
%3D becomes the equal sign (=).
Online Tools for URL Encoding and Decoding
Here are some tools that you can use to encode and decode URLs:

1. URL Encode/Decode by Free Online Tools
How to Use:
Enter your URL or text into the input field.
Click Encode to convert your text into URL-encoded format.
Click Decode to convert URL-encoded characters back to regular characters.
2. URL Decode/Encode by URL-Encode-Decode.com
How to Use:
Paste your URL or text into the textbox.
Click Encode or Decode based on what you want to do.
3. Browserling - URL Encoder/Decoder
How to Use:
Paste your text or URL into the box.
Click Encode or Decode to see the result.
How URL Encoding Works
1. URL Encoding Example
For example, the phrase:

Hello, World!
When URL encoded, becomes:

perl

Hello%2C%20World%21
Explanation:

The comma (,) becomes %2C.
The space ( ) becomes %20.
The exclamation mark (!) becomes %21.
2. URL Decoding Example
If you have the following URL-encoded string:

perl

Hello%2C%20World%21
When URL decoded, it becomes:

Hello, World!
Code Examples for URL Encoding and Decoding
1. URL Encoding in Python
python

import urllib.parse

# Original text
text = "Hello, World!"

# URL encode
encoded_text = urllib.parse.quote(text)

print(f"Encoded: {encoded_text}")
2. URL Decoding in Python
python

import urllib.parse

# URL encoded text
encoded_text = "Hello%2C%20World%21"

# URL decode
decoded_text = urllib.parse.unquote(encoded_text)

print(f"Decoded: {decoded_text}")
3. URL Encoding in JavaScript
javascript

// Original text
let text = "Hello, World!";

// URL encode
let encodedText = encodeURIComponent(text);

console.log("Encoded:", encodedText);
4. URL Decoding in JavaScript
javascript

// URL encoded text
let encodedText = "Hello%2C%20World%21";

// URL decode
let decodedText = decodeURIComponent(encodedText);

console.log("Decoded:", decodedText);
5. URL Encoding in Java (Using URLEncoder)
java

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class URLEncoderExample {
public static void main(String[] args) throws UnsupportedEncodingException {
String text = "Hello, World!";
String encodedText = URLEncoder.encode(text, "UTF-8");
System.out.println("Encoded: " + encodedText);
}
}
6. URL Decoding in Java (Using URLDecoder)
java

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

public class URLDecoderExample {
public static void main(String[] args) throws UnsupportedEncodingException {
String encodedText = "Hello%2C%20World%21";
String decodedText = URLDecoder.decode(encodedText, "UTF-8");
System.out.println("Decoded: " + decodedText);
}
}
7. URL Encoding in C#
csharp

using System;
using System.Web;

class Program {
static void Main() {
string text = "Hello, World!";
string encodedText = HttpUtility.UrlEncode(text);
Console.WriteLine("Encoded: " + encodedText);
}
}
8. URL Decoding in C#
csharp

using System;
using System.Web;

class Program {
static void Main() {
string encodedText = "Hello%2C%20World%21";
string decodedText = HttpUtility.UrlDecode(encodedText);
Console.WriteLine("Decoded: " + decodedText);
}
}
Example URL Encoding and Decoding
Original Text:
kotlin

Hello, how are you? Please check this link: http://example.com/?name=John&age=25
URL Encoded:
perl

Hello%2C%20how%20are%20you%3F%20Please%20check%20this%20link%3A%20http%3A%2F%2Fexample.com%2F%3Fname%3DJohn%26age%3D25
Decoded Text:
kotlin

Hello, how are you? Please check this link: http://example.com/?name=John&age=25
Conclusion
URL encoding ensures that all characters in a URL are safely transmitted by encoding non-safe characters into a URL-compatible format. The reverse process, URL decoding, converts encoded strings back to their original characters.

Online tools are a quick and easy way to perform encoding and decoding.
Programming examples show how to implement encoding and decoding in various languages such as Python, JavaScript, Java, and C#.