URL Encoder Online

URL Encoder Online

URL Encoder is an online tool for encoding URLs. URL encoding stands for encoding certain characters in a URL by replacing them with one or more character triplets that consist of the percent character "%" followed by two hexadecimal digits. The two hexadecimal digits of the triplet(s) represent the numeric value of the replaced character.
Check out the URL decoder online tool at URL Decoder Online.

URL Encoding Example

URL input:
Encoded URL output:

Encode URL in JavaScript

 The encodeURIComponent() function encodes a URI by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two "surrogate" characters).
var uri = "https://javaguides.net/my test.html?name=ram&age29";
console.log("before encode :: " + uri);
var encode = encodeURIComponent(uri); 
console.log("after encode :: " + encode);

var decode = decodeURIComponent(encode);
console.log("after decode :: " + decode);
before encode :: https://javaguides.net/my test.html?name=ram&age29
after encode :: https%3A%2F%2Fjavaguides.net%2Fmy%20test.html%3Fname%3Dram%26age29
after decode :: https://javaguides.net/my test.html?name=ram&age29
Read more about how to encode and decode URL in JavaScript in a blog post at Encode and Decode URL in JavaScript.

URL Encode in Java

Java provides a built-in URLEncoder class, which is a Utility class for HTML form encoding. This class contains static methods for converting a String to the application/x-www-form-urlencoded MIMEformat.
When encoding a String, the following rules apply:
  • The alphanumeric characters "a" through"z", "A" through"Z", and "0" through "9" remain the same.
  • The special characters ".","-", "*", and"_" remain the same.
  • The space character " " is converted into a plus sign "+".
  • All other characters are unsafe and are first converted into one or more bytes using some encoding scheme. Then each byte is represented by the 3-character string"%xy", where xy is the two-digit hexadecimal representation of the byte. The recommended encoding scheme to use is UTF-8. However, for compatibility reasons, if an encoding is not specified, then the default encoding of the platform is used.

URLEncoder Class Example

The URLEncoder utility class provides a encode() method which translates a string into an application/x-www-form-urlencoded format using a specific encoding scheme. This method uses the supplied encoding scheme to obtain the bytes for unsafe characters.
The below program demonstrate the usage of encode() method to encode URL - "https://www.javaguides.net/search?q=core+java+tutorial":
package net.javaguides.network;

import java.io.UnsupportedEncodingException;

import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;

public class URLEncoderExample {

    public static void main(String[] args) throws MalformedURLException, UnsupportedEncodingException {
        // base URL 
        String baseurl = "https://www.javaguides.net/search?q=";

        // String to be encoded 
        String query = "core+java+tutorial";

        System.out.println("URL without encoding :");
        URL url = new URL(baseurl + query);

        // encode() method 
        System.out.println("URL after encoding :");
        url = new URL(baseurl + URLEncoder.encode(query, "UTF-8"));
URL without encoding :
URL after encoding :
Check out how to encode and decode URLs in Java at Java URLEncoder and URLDecoder Class Examples

URL Encoding Table


URL Decoder Online Tool

Check out the URL decoder online tool at URL Decoder Online.

Free Spring Boot Tutorial | Full In-depth Course | Learn Spring Boot in 10 Hours

Watch this course on YouTube at Spring Boot Tutorial | Fee 10 Hours Full Course