URL Encoding/Decoding Tool
pages.urlencode.faq.title
pages.urlencode.faq.whatIsUrlEncoding.title
pages.urlencode.faq.whatIsUrlEncoding.description
pages.urlencode.faq.howUrlEncodingWorks.title
pages.urlencode.faq.howUrlEncodingWorks.description
pages.urlencode.faq.commonEncodedCharacters.title
pages.urlencode.faq.commonEncodedCharacters.description
pages.urlencode.faq.commonEncodedCharacters.tableHeaders.character | pages.urlencode.faq.commonEncodedCharacters.tableHeaders.encoded | pages.urlencode.faq.commonEncodedCharacters.tableHeaders.description |
---|---|---|
Space | %20 | pages.urlencode.faq.commonEncodedCharacters.characters[0].description |
! | %21 | pages.urlencode.faq.commonEncodedCharacters.characters[1].description |
" | %22 | pages.urlencode.faq.commonEncodedCharacters.characters[2].description |
# | %23 | pages.urlencode.faq.commonEncodedCharacters.characters[3].description |
$ | %24 | pages.urlencode.faq.commonEncodedCharacters.characters[4].description |
% | %25 | pages.urlencode.faq.commonEncodedCharacters.characters[5].description |
& | %26 | pages.urlencode.faq.commonEncodedCharacters.characters[6].description |
' | %27 | pages.urlencode.faq.commonEncodedCharacters.characters[7].description |
( | %28 | pages.urlencode.faq.commonEncodedCharacters.characters[8].description |
) | %29 | pages.urlencode.faq.commonEncodedCharacters.characters[9].description |
+ | %2B | pages.urlencode.faq.commonEncodedCharacters.characters[11].description |
, | %2C | pages.urlencode.faq.commonEncodedCharacters.characters[12].description |
/ | %2F | pages.urlencode.faq.commonEncodedCharacters.characters[13].description |
= | %3D | pages.urlencode.faq.commonEncodedCharacters.characters[16].description |
? | %3F | pages.urlencode.faq.commonEncodedCharacters.characters[17].description |
pages.urlencode.faq.urlEncodingImplementation.title
pages.urlencode.faq.urlEncodingImplementation.description
Go
package main
import (
"fmt"
"net/url"
)
func main() {
// Encode a URL
text := "Hello World! Special chars: &?=/";
encoded := url.QueryEscape(text)
fmt.Println("Encoded:", encoded)
// Decode a URL
decoded, err := url.QueryUnescape(encoded)
if err == nil {
fmt.Println("Decoded:", decoded)
}
}
C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
// Function to URL-encode a string
char *url_encode(char *str) {
char *encoded = malloc(strlen(str) * 3 + 1);
char *pstr = str;
char *pbuf = encoded;
while (*pstr) {
if (isalnum(*pstr) || *pstr == '-' || *pstr == '_' || *pstr == '.' || *pstr == '~') {
*pbuf++ = *pstr;
} else if (*pstr == ' ') {
*pbuf++ = '+';
} else {
sprintf(pbuf, "%%%.2X", *pstr);
pbuf += 3;
}
pstr++;
}
*pbuf = '\\0';
return encoded;
}
int main() {
char *text = "Hello World! Special chars: &?=/";
char *encoded = url_encode(text);
printf("Original: %s\\n", text);
printf("Encoded: %s\\n", encoded);
free(encoded);
return 0;
}
PHP
<?php
// URL encoding
$text = "Hello World! Special chars: &?=/";
$encoded = urlencode($text);
echo "Encoded: " . $encoded . "\\n";
// URL decoding
$decoded = urldecode($encoded);
echo "Decoded: " . $decoded . "\\n";
?>
Python
import urllib.parse
# URL encoding
text = "Hello World! Special chars: &?=/"
encoded = urllib.parse.quote(text)
print(f"Encoded: {encoded}")
# URL decoding
decoded = urllib.parse.unquote(encoded)
print(f"Decoded: {decoded}")
JavaScript
// URL encoding
const text = "Hello World! Special chars: &?=/";
const encoded = encodeURIComponent(text);
console.log("Encoded:", encoded);
// URL decoding
const decoded = decodeURIComponent(encoded);
console.log("Decoded:", decoded);
TypeScript
// URL encoding
const text: string = "Hello World! Special chars: &?=/";
const encoded: string = encodeURIComponent(text);
console.log("Encoded:", encoded);
// URL decoding
const decoded: string = decodeURIComponent(encoded);
console.log("Decoded:", decoded);
pages.urlencode.faq.diffBetweenEncodeFunctions.title
pages.urlencode.faq.diffBetweenEncodeFunctions.part1 pages.urlencode.faq.diffBetweenEncodeFunctions.part2 pages.urlencode.faq.diffBetweenEncodeFunctions.part3