URL Decoder Online

URL Decoder Online

URL Decoder is an online tool for decoding URLs. Note that, our tool assumes that the input is encoded using the UTF-8 encoding scheme. The world wide web consortium recommends using the UTF-8 encoding scheme when working with URLs.
Check out URL Encoder Online tool at URL Encoder Online




URL Decode Example

Decoded URL input:
https%3A%2F%2Fwww.javaguides.net%2Fp%2Furl-decoder-online.html
Encoded URL output:
https://www.javaguides.net/p/url-decoder-online.html

What is URL Decoding and why is it required?

URL decoding is the inverse process of URL encoding. It is used to parse query strings or path parameters passed in URLs. It is also used to decode HTML form parameters that are submitted with application/x-www-form-urlencoded MIME format
URLs, as you might know, can only contain a limited set of characters from the US-ASCII character set. These characters include Alphabets (A-Z a-z), Digits (0-9), hyphen (-), underscore (_), tilde (~), and dot (.). Any character outside this allowed set is encoded using URL encoding or Percent encoding.
This is why it becomes necessary to decode query strings or path parameters passed in URLs to get the actual values.

Decode URL in JavaScript

You can decode URI components in Javascript using the decodeURIComponent() function. It performs the inverse operation of encodeURIComponent(). It uses the UTF-8 encoding scheme to decode URI components.

Let's first encode using encodeURIComponent() method and then decode it using decodeURIComponent() function.
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);
Output:
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 Decode in Java

In Java, URLDecoder class provides decode() method which decodes an application/x-www-form-urlencoded string using a specific encoding scheme.
The below program demonstrate the usage of the decode() method:
package net.javaguides.network;

import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;

public class URLDecoderExample {

    public static void main(String[] args) throws UnsupportedEncodingException, MalformedURLException {
        // 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);
        System.out.println(url);

        // encode() method
        System.out.println("URL after encoding :");

        String encodedStr = URLEncoder.encode(query, "UTF-8");
        url = new URL(baseurl + encodedStr);
        System.out.println(url);

        // decode url process
        System.out.println("Encoded URL :");
        System.out.println(baseurl + encodedStr);

        // decode() method
        System.out.println("Decoded URL :");
        String decode = URLDecoder.decode(encodedStr, "UTF-8");
        System.out.println(baseurl + decode);
    }
}
Output:
URL without encoding :
https://www.javaguides.net/search?q=core+java+tutorial
URL after encoding :
https://www.javaguides.net/search?q=core%2Bjava%2Btutorial
Encoded URL :
https://www.javaguides.net/search?q=core%2Bjava%2Btutorial
Decoded URL :
https://www.javaguides.net/search?q=core+java+tutorial

Our example uses UTF-8 encoding for decoding the URLs. You should always use UTF-8 to avoid incompatibilities with other systems. That is what the world wide web consortium recommends.
Check out how to encode and decode URLs in Java at Java URLEncoder and URLDecoder Class Examples

URL Encode Online Tool

URL Encoder Online

Comments