New to URL encoding? Learn what it is, why it matters, and how to use it with simple real-world examples and beginner-friendly explanations.
If you're new to web development or just starting to explore how the internet works, you might have come across something called URL encoding. At first, it may look confusing—strange symbols like %20, %3A, or %2F appearing inside URLs.
But don’t worry. In this beginner-friendly guide, we will break everything down step by step so you can understand URL encoding from scratch.
By the end of this guide, you will know:
You can also try it yourself here:
👉 https://www.mydevtoolhub.com/tools/url-encoder-decoder
Before understanding URL encoding, let's quickly understand what a URL is.
A URL (Uniform Resource Locator) is simply the address of a webpage on the internet.
https://www.example.com/search?q=hello
This URL has multiple parts:
https:// → protocolwww.example.com → domain/search → path?q=hello → query parameterNow here’s the important part: URLs can only contain certain types of characters.
Imagine you want to search for something like:
hello world
If you directly put this into a URL like this:
https://example.com/search?q=hello world
This will break the URL because spaces are not allowed.
Similarly, characters like:
@#&=have special meanings in URLs.
So what do we do?
👉 We use URL encoding.
URL encoding is the process of converting unsafe or special characters into a format that can be safely used inside a URL.
This is done using a percent (%) followed by hexadecimal values.
Space → %20
So:
hello world → hello%20world
Now the URL becomes valid:
https://example.com/search?q=hello%20world
URL encoding is important because it ensures that:
Without encoding, your application may:
Think of URL encoding like sending a parcel.
If you write an address with unclear symbols or messy handwriting, the parcel may go to the wrong place.
So instead, you format the address properly so the delivery system understands it.
👉 URL encoding does the same thing for web addresses.
Here are some basic examples you should know:
| Character | Encoded Value |
|---|---|
| Space | %20 |
| @ | %40 |
| # | %23 |
| & | %26 |
| = | %3D |
| + | %2B |
Let’s take a simple example:
hello@world.com
@ becomes %40hello%40world.com
Now this can safely be used in a URL.
URL decoding is the opposite process.
It converts encoded values back to their original characters.
hello%20world → hello world
This is useful when reading data from URLs.
If you search for:
how to learn coding
The URL becomes:
https://www.google.com/search?q=how%20to%20learn%20coding
email=test@example.com
Becomes:
email=test%40example.com
https://example.com?redirect=https://google.com
Becomes:
https://example.com?redirect=https%3A%2F%2Fgoogle.com
Instead of doing it manually, you can use a tool.
👉 Try this free tool:
https://www.mydevtoolhub.com/tools/url-encoder-decoder
Just paste your text and get instant encoded or decoded results.
JavaScript provides simple functions for encoding.
const text = "hello world";
const encoded = encodeURIComponent(text);
console.log(encoded);
hello%20world
const decoded = decodeURIComponent(encoded);
console.log(decoded);
Spaces must always be encoded as %20.
This often leads to mistakes. Use tools instead.
Characters like & and = have meaning in URLs.
Use proper functions depending on the case.
You should use URL encoding when:
If you are unsure whether something needs encoding, follow this rule:
👉 If it contains spaces or special characters, encode it.
URL encoding converts unsafe characters into a safe format so they can be used in web addresses.
Because spaces are not allowed in URLs, so they are replaced with %20.
Yes, especially when working with APIs, forms, and dynamic URLs.
You can, but it's not recommended. Use tools or built-in functions instead.
Encoding converts text into a URL-safe format, while decoding converts it back to original text.
URL encoding may seem small, but it plays a big role in web development.
As a beginner, understanding this concept will help you:
Instead of guessing, use a reliable tool to make your work easier:
👉 https://www.mydevtoolhub.com/tools/url-encoder-decoder
Start practicing today and master this essential web development skill.
Learn how to handle special characters, Unicode, emojis, and spaces in URL encoding with real examples and edge-case fixes.
Learn how to debug URL encoding issues in production using logs, network tools, and advanced developer techniques.
Master URL encoding with real-world examples including forms, search queries, APIs, and redirects. A practical guide for developers.