<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Code Wiz Tools</title>
    <description>The latest articles on DEV Community by Code Wiz Tools (@codewiztools).</description>
    <link>https://dev.to/codewiztools</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3991208%2Fcad72945-b0dd-456d-beaa-6862956a832d.png</url>
      <title>DEV Community: Code Wiz Tools</title>
      <link>https://dev.to/codewiztools</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/codewiztools"/>
    <language>en</language>
    <item>
      <title>URL Encoding vs Percent Encoding — Are They the Same Thing?</title>
      <dc:creator>Code Wiz Tools</dc:creator>
      <pubDate>Sat, 20 Jun 2026 14:38:43 +0000</pubDate>
      <link>https://dev.to/codewiztools/url-encoding-vs-percent-encoding-are-they-the-same-thing-553j</link>
      <guid>https://dev.to/codewiztools/url-encoding-vs-percent-encoding-are-they-the-same-thing-553j</guid>
      <description>&lt;p&gt;Most developers use these two terms interchangeably. Stack Overflow threads mix them up. Documentation switches between them mid-paragraph. Even MDN uses both terms in the same article.&lt;br&gt;
So are they the same thing — or is there a real difference?&lt;br&gt;
Short answer: they refer to the same mechanism, but come from different contexts. Understanding which is which will save you from some genuinely painful debugging sessions.&lt;br&gt;
&lt;strong&gt;What is URL Encoding?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codewiztools.com/tools/url-encoder.html" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpd5jf0rutaiwj9e4tf4m.PNG" alt=" " width="800" height="460"&gt;&lt;/a&gt;&lt;br&gt;
URL encoding is the informal, developer-facing term for converting unsafe characters in a URL into a format that can be safely transmitted over the internet.&lt;br&gt;
The core problem it solves: URLs can only contain a limited set of characters. Letters (A–Z, a–z), digits (0–9), and a handful of symbols (-, _, ., ~) are always safe. Everything else — spaces, ampersands, equal signs, non-English characters — can break URL parsing if left as-is.&lt;br&gt;
URL encoding converts those unsafe characters into a % sign followed by a two-digit hexadecimal code.&lt;br&gt;
hello world  →  hello%20world&lt;br&gt;
café         →  caf%C3%A9&lt;br&gt;
q=a&amp;amp;b        →  q%3Da%26b&lt;br&gt;
This term became common because browsers, frameworks, and tutorials all started calling it "URL encoding" — it is descriptive and practical.&lt;br&gt;
&lt;strong&gt;What is Percent Encoding?&lt;/strong&gt;&lt;br&gt;
Percent encoding is the official, RFC-defined term for the exact same mechanism.&lt;br&gt;
It is formally defined in RFC 3986 — the Internet standard that defines the syntax of URIs (Uniform Resource Identifiers). The spec calls it "percent-encoding" because every encoded character is represented as a percent sign followed by two hexadecimal digits.&lt;br&gt;
From RFC 3986:&lt;/p&gt;

&lt;p&gt;A percent-encoding mechanism is used to represent a data octet in a component when that octet's corresponding character is outside the allowed set or is being used as a delimiter of, or within, the component.&lt;/p&gt;

&lt;p&gt;So when you are reading a W3C spec, an HTTP RFC, or any formal documentation — you will see "percent encoding." When you are reading a tutorial, a Stack Overflow answer, or framework docs — you will see "URL encoding."&lt;br&gt;
&lt;strong&gt;Same thing. Different contexts.&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;The Real Difference You Actually Need to Know&lt;/strong&gt;&lt;br&gt;
Here is where it gets practical — and where most bugs come from.&lt;br&gt;
In JavaScript, you have two built-in functions for encoding URLs. They are not interchangeable:&lt;br&gt;
&lt;strong&gt;encodeURI vs encodeURIComponent — Code Examples&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;The Wrong Way (a very common mistake)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;const searchUrl = "&lt;a href="https://example.com/search?q=hello" rel="noopener noreferrer"&gt;https://example.com/search?q=hello&lt;/a&gt; world&amp;amp;lang=en";&lt;br&gt;
// WRONG — using encodeURIComponent on a full URL&lt;br&gt;
encodeURIComponent(searchUrl);&lt;br&gt;
// → "https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Dhello%20world%26lang%3Den"&lt;br&gt;
// The URL is now completely broken — slashes, colons, question marks all encoded&lt;br&gt;
This is the most common mistake. The URL looks encoded, but it is useless — a browser cannot parse it as a URL anymore.&lt;br&gt;
&lt;strong&gt;The Right Way — encodeURI for full URLs&lt;/strong&gt;&lt;br&gt;
const searchUrl = "&lt;a href="https://example.com/search?q=hello" rel="noopener noreferrer"&gt;https://example.com/search?q=hello&lt;/a&gt; world&amp;amp;lang=en";&lt;/p&gt;

&lt;p&gt;// CORRECT — encodeURI preserves URL structure&lt;br&gt;
encodeURI(searchUrl);&lt;br&gt;
// → "&lt;a href="https://example.com/search?q=hello%20world&amp;amp;lang=en" rel="noopener noreferrer"&gt;https://example.com/search?q=hello%20world&amp;amp;lang=en&lt;/a&gt;"&lt;br&gt;
// Only the space is encoded — the URL structure is intact&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Right Way — encodeURIComponent for query values&lt;/strong&gt;&lt;br&gt;
const userInput = "hello world &amp;amp; more";&lt;br&gt;
const baseUrl   = "&lt;a href="https://example.com/search?q=" rel="noopener noreferrer"&gt;https://example.com/search?q=&lt;/a&gt;";&lt;/p&gt;

&lt;p&gt;// CORRECT — encode only the VALUE, not the whole URL&lt;br&gt;
const fullUrl = baseUrl + encodeURIComponent(userInput);&lt;br&gt;
// → "&lt;a href="https://example.com/search?q=hello%20world%20%26%20more" rel="noopener noreferrer"&gt;https://example.com/search?q=hello%20world%20%26%20more&lt;/a&gt;"&lt;br&gt;
// The &amp;amp; inside the value is encoded to %26 — no ambiguity&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-world example — passing a redirect URL in a query string&lt;/strong&gt;&lt;br&gt;
// You want to pass this URL as a query parameter value&lt;br&gt;
const redirectUrl = "&lt;a href="https://myapp.com/dashboard?tab=settings" rel="noopener noreferrer"&gt;https://myapp.com/dashboard?tab=settings&lt;/a&gt;";&lt;/p&gt;

&lt;p&gt;// WRONG — this breaks the outer URL's query string&lt;br&gt;
"&lt;a href="https://auth.example.com/login?redirect=" rel="noopener noreferrer"&gt;https://auth.example.com/login?redirect=&lt;/a&gt;" + redirectUrl;&lt;br&gt;
// → "&lt;a href="https://auth.example.com/login?redirect=https://myapp.com/dashboard?tab=settings" rel="noopener noreferrer"&gt;https://auth.example.com/login?redirect=https://myapp.com/dashboard?tab=settings&lt;/a&gt;"&lt;br&gt;
// The second ? and = confuse every URL parser&lt;/p&gt;

&lt;p&gt;// CORRECT — encode the redirect value first&lt;br&gt;
"&lt;a href="https://auth.example.com/login?redirect=" rel="noopener noreferrer"&gt;https://auth.example.com/login?redirect=&lt;/a&gt;" + encodeURIComponent(redirectUrl);&lt;br&gt;
// → "&lt;a href="https://auth.example.com/login?redirect=https%3A%2F%2Fmyapp.com%2Fdashboard%3Ftab%3Dsettings" rel="noopener noreferrer"&gt;https://auth.example.com/login?redirect=https%3A%2F%2Fmyapp.com%2Fdashboard%3Ftab%3Dsettings&lt;/a&gt;"&lt;br&gt;
// Clean — outer URL parses correctly, inner URL recoverable via decodeURIComponent&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The One-Line Rule to Remember&lt;/strong&gt;&lt;br&gt;
Use encodeURIComponent when encoding a value that goes inside a URL.&lt;br&gt;
Use encodeURI when encoding a complete URL as a string.&lt;/p&gt;

&lt;p&gt;If you remember nothing else from this article, remember that line. It will prevent 90% of URL encoding bugs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tool&lt;/strong&gt;&lt;br&gt;
If you need to quickly encode or decode URLs without writing code — I built a free URL Encoder &amp;amp; Percent Encoding Converter that supports both encodeURI and encodeURIComponent modes, handles full Unicode including Arabic and Urdu, and runs 100% in the browser with no data sent to any server.&lt;br&gt;
It also includes the full percent encoding reference table and a real-time character counter — useful when debugging API calls or OAuth redirect parameters.&lt;br&gt;
&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
URL encoding and percent encoding are the same mechanism — one term is informal and developer-friendly, the other is the official RFC standard. The distinction that actually matters day-to-day is encodeURI vs encodeURIComponent — and using the wrong one is responsible for a surprising number of broken integrations, failed API calls, and corrupted redirect flows.&lt;br&gt;
When in doubt: if you are encoding a value that goes inside a URL, use encodeURIComponent. Every time.&lt;/p&gt;

&lt;p&gt;Found this useful? I am building &lt;a href="https://codewiztools.com/" rel="noopener noreferrer"&gt;CodeWizTools&lt;/a&gt; — a collection of free, browser-based utilities for developers and students. No login, no server uploads, 100% private.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
