URL - Encoder/Decoder

With this tool, you can easily encode and decode binary data and URL that are transmitted over internet.

URL encoding

URL encoding is the process of converting the characters in a URL into a format that can be safely sent across the web. In other words, URL encoding (sometimes known as "percent encoding") is the transformation of a URL into a machine-readable format when it is passed through the internet.

Why is URL encoding done?

When a URL is transmitted through the internet, it must be properly formatted in order to reach its destination server intact. URL encoding helps convert unsafe characters (such as spaces and symbols) into associated ASCII values. This is essential for sharing the URL on the internet.

How URL encoding works

URL encoding identifies the characters that fall out of the ASCII set and converts them into an appropriate value. The character format will be replaced by "%" followed by the hex value of that particular character.

URL decoding

URL decoding is similar to encoding, but the process is reversed. The encoded URL is converted back to its original form, inclusive of the spaces and special characters, if any.

For example:

TEXTEncoded Form
The cost of an apple is $2.The%20cost%20of%20an%20apple%20is%20%242.

In the above example, the space between each word is replaced by "%20", where 20 corresponds to the hex code of a space. Similarly, the dollar sign ($) is replaced by a percent sign (%) followed by its hex code, 24. Some encoders use a "+" instead of a "%20" to replace the spaces in a URL.

Base64 encoding

Base64 encoding is the process of converting binary codes into ASCII combinations and is performed when you need to transmit or store binary data in the form of text. Any form of data can be converted into a long piece of plain text. Doing so is a simple way to prepare the data to be transmitted across channels. Base64 is strictly an encoding mechanism and does not offer any additional security to seal or protect the data.

Base64, as the name suggests, uses 64 unique characters to represent 6 bits of data for conversion. Suppose your data is made of 6-bit bytes and your network uses 7 bits for transmission; the transmission of the data will not be possible, as the byte stream conversion used in each case will be different. This is where Base64 comes into play. It contains 64 characters with:

  • Upper and lower case alphabets (A-Z and a-z)
  • 10 numeric values (0-9)
  • Two possible special characters (+, /) depending on the OS.

Steps to convert a piece of text into its Base64 encoded form:

  • Determine whether the number of characters in your text is a multiple of 3. If not, pad the text with a special character, such as the equals symbol (=).
  • Convert the characters in the string into their respective ASCII values.
  • The ASCII values will then be converted into their binary and decimal forms.
  • With the help of a Base64 table, the resultant will be encoded.

Example of Base64 conversion:

Text:

ART

Step 1:

Since ART is comprised of 3 characters, additional padding is not required.

Step 2:

Convert characters to ASCII values

Step 3:

Convert ASCII values to binary codes

  • 65: 01000001
  • 82: 01010010
  • 84: 01010100

In order to convert the binary code into a decimal form, split the binary codes into a 6-segment pattern. (65+82+84 = 010000010101001001010100)

  • 010000: 16
  • 010101: 21
  • 001001: 9
  • 010100: 20
Step 4:

Look up the decimals on the Base64 table.

  • 16: Q
  • 21: V
  • 9: J
  • 20: U

The Base64 resultant of ARTwill be QVJU.

base-64-encoding

Base64 lookup table:

DecimalBase64 conversion
A - Z0 - 25
a - z26 - 51
0 - 952 - 61
+62
/63

Base64 decoding

The process of decoding a string back to its original form is quite similar to the encoding process. It is essentially the same process in reverse.

Frequently Asked Questions

  • Which characters are used in Base64 encoding?

    Since Base64 encoding converts binary data into an ASCII value, the characters used in this system include upper and lower case letters (A-Z, a-z), numericals (0-9), and special characters (like "+","=", and "/").
  • What are the benefits of Base64 encoding?

    When you want to store a non-textual file, like an image or a video, in the form of a textual file like, HTML or JSON, Base64 encoding scheme can be used. Base64 images load faster and are more compatible.
  • Does Base64 encoding increase the size of your data?

    Once the data is passed through the encoding process, the size of the resultant text could be three times that of the original data. There are several factors that determine the length of the resultant string, like the size of the source text, its modulo by 3, and padding of additional characters (like "=" or "/").
  • What is the difference between Base64 encoding and URL encoding?

    Base64 encoding is used when you need to transmit or store data across the web in binary format, whereas URL encoding acts as a shield over the characters in a URL that cannot be safely transmitted over the internet. Both encoding processes increase the size of the original text, which can be reverted to its original form upon decoding.