Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • HTML Tutorial
  • HTML Exercises
  • HTML Tags
  • HTML Attributes
  • Global Attributes
  • Event Attributes
  • HTML Interview Questions
  • HTML DOM
  • DOM Audio/Video
  • HTML 5
  • HTML Examples
  • Color Picker
  • A to Z Guide
  • HTML Formatter
Open In App

HTML URL Encoding

Last Updated : 22 Feb, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

A Uniform Resource Locator (URL) is simply the address of a website to access the website content. Web browsers retrieve pages from web servers using a URL (Uniform Resource Locator).

What is URL Encoding?

URL Encoding is the process of converting the URL into a valid format that is accepted by web browsers. 

Only certain characters are allowed to be used in the URL like alphabets A-Z and a-z, numbers 0-9, and a few special characters. They can be used as it is but the rest of the characters that are not in this list are used after encoding them to a suitable form.

URL Encoding takes place by replacing all the characters that are not allowed by a % sign followed by two hexadecimal digits. These two hexadecimal values represent the numerical values of the character in the ASCII character set.

For example, a space is not acceptable in a URL and is replaced by a '%20' or a '+' sign while encoding. Similarly, a $ sign is replaced by '%24'.

URL Syntax

A web address follows these syntax rules:

scheme://prefix.domain:port/path/filename

//Example
https://www.geeksforgeeks.org/
  • Scheme: It specifies the protocol used for communication, such as "https://" for secure communication or "http://" for unsecured communication.
  • Prefix: It is an optional subdomain or www indicating the location of the resource within the domain.
  • Domain: Identifies the website's primary address, like "example.com", indicating its unique location on the Internet.
  • Port: Optional and signifies a specific endpoint for communication. Common values are 80 for HTTP and 443 for HTTPS.
  • Path: It specifies the location or directory on the server where the resource is located.
  • Filename: It refers to the specific file or resource within the specified path.

Reserved Characters

Certain characters sometimes have special meanings in the URL and it can be used in both ways. For example, the '/' character is a reserved character and it has a special meaning when being used as a delimiter to separate the paths of a URL. Here it is used by encoding it to '%2F'. Else when it has no special purpose it can be used normally. There are many reserved characters which are listed below:

CharacterEncoded Form
!%21
*%2A
'%27
(%28
)%29
;%3B
:%3A
@%40
&%26
=%3D
+%2B
$%24
,%2C
/%2F
?%3F
#%23
[%5B
]%5D

Some characters need to be encoded while some don't need to be. Here is the classification shows the group of characters that need to be encoded.

  • Safe Characters: Alphanumeric i.e. 0-9, a-z, and A-Z, special characters $, -, _, ., +, !, *, ', (, ), are reserved characters used for their reserved purposes. These characters have no need to be encoded.
  • ASCII Control characters: It includes characters ranging from 00-1F in hex (0-31 decimal) and 7F (127 decimal). These characters needs to be encoded.
  • Non-ASCII Control characters: It includes 80-FF in hex (128-255 decimal). These characters needs to be encoded.
  • Reserved characters: These characters are used for a special purpose and they require encoding.
  • Unsafe characters: This character can be misunderstood within URLs for various reasons. So it requires encoding. The characters < and > are unsafe because they are used as the delimiters around URLs in free text, the quote mark (" ") is unsafe as it is used to delimit URLs in some systems.

Unsafe characters

CharacterEncoded Form
space%20
"%22
<%3C
>%3E
#%23
%%25
{%7B
}%7D
|%7C
\%5C
^%5E
~%7E
[%5B
]%5D

URL Encoded Characters

CHARACTERENCODED FORM
backspace%08
tab%09
linefeed%0A
c return%0D
space%20
!%21
"%22
#%23
$%24
%%25
&%26
'%27
(%28
)%29
*%2A
+%2B
,%2C
-%2D
.%2E
/%2F
0%30
1%31
2%32
3%33
4%34
5%35
6%36
7%37
8%38
9%39
:%3A
;%3B
<%3C
=%3D
>%3E
?%3F
@%40
A%41
B%42
C%43
D%44
E%45
F%46
G%47
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
Ù%C3%99
Ú%C3%9A
Û%C3%9B
Ü%C3%9C
Ý%C3%9D
Þ%C3%9E
ß%C3%9F
à%C3%A0
á%C3%A1
â%C3%A2
ã%C3%A3
ä%C3%A4
å%C3%A5
æ%C3%A6
ç%C3%A7
è%C3%A8
é%C3%A9
ê%C3%AA
ë%C3%AB
ì%C3%AC
í%C3%AD
î%C3%AE
ï%C3%AF
ð%C3%B0
ñ%C3%B1
ò%C3%B2
ó%C3%B3
ô%C3%B4
õ%C3%B5
ö%C3%B6
÷%C3%B7
ø%C3%B8
ù%C3%B9
ú%C3%BA
û%C3%BB
ü%C3%BC
ý%C3%BD
þ%C3%BE
ÿ%C3%BF

P

prakhar7
Improve
Article Tags :
  • Web Technologies
  • HTML
  • HTML-Basics

Similar Reads

    HTML Tutorial
    HTML stands for HyperText Markup Language. It is the standard language used to create and structure content on the web. It tells the web browser how to display text, links, images, and other forms of multimedia on a webpage. HTML sets up the basic structure of a website, and then CSS and JavaScript
    11 min read
    HTML Introduction
    HTML stands for Hyper Text Markup Language, which is the core language used to structure content on the web. It organizes text, images, links, and media using tags and elements that browsers can interpret. As of 2025, over 95% of websites rely on HTML alongside CSS and JavaScript, making it a fundam
    6 min read
    HTML Editors
    An HTML Editor is a software application designed to help users create and modify HTML code. It often includes features like syntax highlighting, tag completion, and error detection, which facilitate the coding process. There are two main types of HTML editors: Text-Based Editors - Allow direct codi
    5 min read
    HTML Basics
    HTML (HyperText Markup Language) is the standard markup language used to create and structure web pages. It defines the layout of a webpage using elements and tags, allowing for the display of text, images, links, and multimedia content. As the foundation of nearly all websites, HTML is used in over
    6 min read
    HTML Comments
    HTML comments are used to add notes or explanations in the HTML code that are not displayed by the browser.They are useful for documenting the code, making it easier to understand and maintain.To add a comment, use the syntax <!-- your comment here -->. HTML<!-- This is a comment and will n
    4 min read
    HTML Elements
    An HTML Element consists of a start tag, content, and an end tag, which together define the element's structure and functionality. Elements are the basic building blocks of a webpage and can represent different types of content, such as text, links, images, or headings.For example, the <p> ele
    5 min read
    HTML Attributes
    HTML Attributes are special words used within the opening tag of an HTML element. They provide additional information about HTML elements. HTML attributes are used to configure and adjust the element's behavior, appearance, or functionality in a variety of ways. Each attribute has a name and a value
    8 min read
    HTML Headings
    HTML headings are used to define the titles and subtitles of sections on a webpage. They help organize the content and create a structure that is easy to navigate.Proper use of headings enhances readability by organizing content into clear sections.Search engines utilize headings to understand page
    4 min read
    HTML Paragraphs
    A paragraph in HTML is simply a block of text enclosed within the <p> tag. The <p> tag helps divide content into manageable, readable sections. It’s the go-to element for wrapping text in a web page that is meant to be displayed as a distinct paragraph.Syntax:<p> Some Content...
    5 min read
    HTML Text Formatting
    HTML text formatting refers to the use of specific HTML tags to modify the appearance and structure of text on a webpage. It allows you to style text in different ways, such as making it bold, italic, underlined, highlighted, or struck-through. Table of ContentCategories of HTML Text FormattingLogic
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences