URL Encode / Decode
Convert URLs and web strings into a safe percent-encoded format — or restore encoded URLs back to their original form. Fast, accurate, and runs entirely in your browser.
Each character that is not allowed in a URL — or that has a special meaning — is replaced by a % followed by two hexadecimal digits representing the byte value.
Reserved Characters Reference
| Character | Encoded | Common Use / Meaning |
|---|---|---|
| space | %20 | Whitespace — must always be encoded in URLs |
| ! | %21 | Sub-delimiter (sometimes left as-is) |
| # | %23 | Fragment identifier separator |
| $ | %24 | Sub-delimiter |
| & | %26 | Query parameter separator |
| ' | %27 | Sub-delimiter (often left as-is by encodeURIComponent) |
| ( | %28 | Sub-delimiter (often left as-is) |
| ) | %29 | Sub-delimiter (often left as-is) |
| * | %2A | Sub-delimiter (often left as-is) |
| + | %2B | Means "space" in form-encoded data |
| , | %2C | Sub-delimiter |
| / | %2F | Path separator |
| : | %3A | Scheme / port separator |
| ; | %3B | Parameter separator |
| = | %3D | Key/value separator in query strings |
| ? | %3F | Query string start |
| @ | %40 | Userinfo separator |
| [ | %5B | IPv6 host start |
| ] | %5D | IPv6 host end |
| % | %25 | Percent sign itself — must always be encoded |
When to Use Each Function
encodeURIComponent
Encodes everything except A–Z a–z 0–9 - _ . ! ~ * ' ( ). Use it for individual query parameter values, such as ?q= values, where even &, =, and ? must be encoded.
encodeURI
Encodes a complete URL while preserving reserved characters that have structural meaning (: / ? # [ ] @ ! $ & ' ( ) * + , ; =). Use it when you have a full URL that just needs unsafe characters escaped.
Plus vs %20
In application/x-www-form-urlencoded data (HTML forms), spaces become +. In real URLs and percent-encoding, spaces become %20. The "Treat + as space" option lets you decode form-encoded data correctly.
UTF-8 Encoding
Non-ASCII characters (like emojis or accented letters) are first converted to UTF-8 bytes, and each byte is then percent-encoded. For example, é → %C3%A9 (two bytes), and 🎉 → %F0%9F%8E%89 (four bytes).
The Ultimate Guide to URL Encode / Decode: How to Fix Broken Web Links
Have you ever clicked a link and landed on a broken page with a weird error message? Or maybe you tried to share a link with a space in it, only to find the URL cut off halfway through? This happens because web browsers and servers are very strict about what characters they allow in a URL.
Our URL Encode / Decode Calculator is a free, fast, and secure tool designed to solve this exact problem. Whether you are a web developer building an API, a digital marketer tracking campaigns, or just someone trying to share a complex link, this tool helps you translate text into a web-safe format (and back again).
In this comprehensive guide, we will explain exactly what URL encoding is, how it works under the hood, and how to use our tool to fix your links in seconds.
What is URL Encode / Decode?
Definition and Purpose
URL Encoding—also known as Percent-Encoding—is the process of converting characters into a format that can be safely transmitted over the internet.
The URLs you see in your browser address bar can only contain a specific subset of ASCII characters: letters (A-Z), numbers (0-9), and a few special symbols like hyphens and underscores. When you try to put spaces, ampersands (&), or non-English characters (like é or ñ) into a URL, the system breaks. URL encoding solves this by replacing the unsafe characters with a percent sign (%) followed by a two-digit hexadecimal code.
URL Decoding is simply the reverse process. It takes a string filled with %20 and %26 symbols and translates them back into readable human text.
Background and Importance
The rules for URLs were written decades ago in a document called RFC 3986. Back then, computers primarily used the English alphabet. Today, the internet is global, and URLs need to support emojis, Arabic script, Chinese characters, and complex data structures.
If you try to send raw data containing spaces or question marks through a URL, the server might interpret a space as the end of the URL, or mistake an ampersand for a parameter separator. Encoding ensures that the data arrives exactly as you intended.
How This Calculator Works
Our URL Encode / Decode calculator runs entirely in your browser. This means your data is never uploaded to a server, making it completely secure for private links and sensitive parameters.
Inputs and Options
When you use the tool, you have three main inputs:
- Input Text Box: This is where you paste your URL or text.
- Mode Toggle (Encode / Decode): Choose whether you want to convert plain text to a URL-safe format, or convert an encoded URL back to plain text.
- Advanced Options:
- Use
encodeURIComponent: Check this box if you are encoding a parameter value (like a search query). It encodes every special character. Uncheck it if you are encoding a full, complete URL (it will leave structural characters like/and?alone). - Treat
+as space: In HTML form submissions, spaces are often sent as+signs instead of%20. Check this box if you are decoding data from a web form. - Live Update: Instantly updates the output as you type.
- Use
Outputs
Once you process your text, the calculator provides:
- Output Text Box: The fully encoded or decoded result.
- Character Breakdown: A visual chip showing exactly which characters were changed (e.g.,
space → %20). - Live Stats: A count of the input length, output length, special characters transformed, and total bytes.
The Logic Explained (The “Formula”)
URL encoding doesn’t use a traditional math formula, but it does use a strict logical formula based on the ASCII and UTF-8 character tables.
The Encoding Rule
The logic is simple: if a character is not an unreserved character, it must be converted.
Unreserved Characters (Never encoded):
- Letters:
A-Z a-z - Numbers:
0-9 - Symbols:
-(hyphen),_(underscore),.(period),!(exclamation),~(tilde),*(asterisk),'(single quote),(,)(parentheses).
The Conversion Formula: For every character that is not on the list above:
- Look up the character’s byte value in the UTF-8 table.
- Convert that byte value into a two-digit hexadecimal number.
- Prepend a
%sign.
Variable Explanation
%: The escape character. It tells the browser, “The next two characters are a hex code, not regular text.”XX: The two-digit hexadecimal representation of the byte.
Example Calculation
Let’s encode the word “café”.
cis a letter. It stays asc.ais a letter. It stays asa.fis a letter. It stays asf.éis not a standard ASCII letter. In UTF-8, the characteréis represented by two bytes:- Byte 1: 195 (Hex:
C3) - Byte 2: 169 (Hex:
A9)
- Byte 1: 195 (Hex:
So, é becomes %C3%A9. The final encoded word is: caf%C3%A9.
Common Mistakes in the Logic
A frequent mistake is confusing encodeURI with encodeURIComponent.
encodeURIkeeps URL structure intact.https://site.com/stayshttps://site.com/.encodeURIComponentdestroys URL structure.https://site.com/becomeshttps%3A%2F%2Fsite.com%2F.
If you encode an entire URL using encodeURIComponent, the link will break because the browser won’t know where the domain ends and the path begins.
How to Use the Calculator
Using the tool on Calculators4All.com is straightforward. Follow these steps:
- Choose your mode: Click the “Encode” or “Decode” button at the top of the tool.
- Set your options:
- If you are encoding a single search term or query parameter, make sure “Use encodeURIComponent” is checked.
- If you are decoding data from a web form, check “Treat + as space”.
- Paste your text: Click inside the “Input Text” box and paste your URL or string.
- Review the output: The “Output” box will instantly display the translated text (if Live Update is on).
- Copy or Download: Click the “Copy Output” button to copy the text to your clipboard, or click “Download” to save it as a
.txtfile. - Swap if needed: Click the “Swap” button to instantly move the output text into the input box and switch your mode. This is perfect for verifying your work!
Pro Tip: Use the “Sample” button to instantly load a test URL. This is a great way to see how the tool handles emojis, spaces, and complex query parameters before pasting your own data.
Example Calculations
To fully understand how this works, let’s look at some practical, real-world examples of URL encoding and decoding.
Example 1: Basic Encoding (Beginner)
Scenario: You want to share a search link for “hello world”.
- Input:
hello world - Option Used:
encodeURIComponent - Output:
hello%20world - Why: The space character is not allowed in URLs. Its hex value is
20, so it becomes%20.
Example 2: Advanced Encoding with Query Parameters
Scenario: You are building an API URL with a search query that contains an ampersand.
- Input:
https://example.com/search?q=shoes & boots&sort=asc - Option Used:
encodeURIComponent(applied only to the parameter valueshoes & boots) - Output:
https://example.com/search?q=shoes%20%26%20boots&sort=asc - Why: If you didn’t encode the
&in “shoes & boots”, the server would think you are starting a new parameter calledsort=asc. Encoding the&to%26tells the server it is just part of the search term.
Example 3: Decoding Web Form Data
Scenario: You received a URL string from a submitted HTML form and need to read it.
- Input:
name=John+Doe&email=john%40example.com - Option Used: Decode + Treat
+as space - Output:
name=John Doe&email=john@example.com - Why: Web forms encode spaces as
+signs. The@symbol was encoded as%40.
Summary Table: Reserved Characters
Here is a quick reference table for the most common URL-encoded characters. You can use our tool to test these instantly.
Original Character | Encoded Value | Common Meaning in URL |
|---|---|---|
| Space | %20 (or +) | Whitespace |
& | %26 | Parameter separator |
= | %3D | Key/value separator |
? | %3F | Start of query string |
/ | %2F | Path separator |
: | %3A | Scheme/port separator |
@ | %40 | Userinfo separator |
% | %25 | Percent sign itself |
# | %23 | Fragment identifier |
Benefits of Using Our URL Encode/Decode Tool
Using a dedicated, browser-based calculator offers numerous advantages over manual conversion or writing custom scripts.
- Instant Results: No waiting for servers to process data. The conversion happens instantly in your browser.
- 100% Private: Because everything runs client-side, your sensitive URLs and API keys are never transmitted over the internet.
- Error Prevention: Manual conversion is prone to typos. The tool guarantees accurate hexadecimal conversion every time.
- Character Breakdown: The visual “chips” show you exactly what was changed, helping you learn and debug.
- Handles Emojis and UTF-8: Easily processes complex multi-byte characters like emojis or non-Latin scripts without crashing.
- Dual Functionality: Instantly switch between encoding and decoding using the “Swap” button.
- No Installation Required: Works on any device with a browser—Windows, Mac, Linux, iOS, or Android.
- Copy and Download: One-click copying to the clipboard or downloading as a text file for your records.
- Customizable Rules: Toggle between
encodeURIComponentandencodeURIto handle both full URLs and individual parameters. - Free and Unlimited: No paywalls, no trial limits, and no hidden fees.
Features of the Calculator
Our tool is packed with features designed for both beginners and advanced technical users:
- Smart Mode Toggle: Easily switch between “Encode” and “Decode” tabs.
- Live Byte Counter: Shows you the exact byte size of your output, crucial for systems with URL length limits (like SMS gateways or older databases).
- Special Character Counter: Counts how many characters needed to be transformed.
- Visual Transformation Chips: A visual log showing
Original → Encodedfor every changed character. - Responsive Design: The interface adapts perfectly to your screen, whether you are on a 4K monitor or a smartphone.
Applications: Who Uses This Tool?
URL encoding is a fundamental concept across multiple industries. Here is how different professionals use this calculator:
Web Development and API Integration
Developers constantly build and consume APIs. When sending data to an API via a GET request (in the URL), any special characters must be encoded. If a user types I love Python & Java! into a search box, the developer must encode that string to I%20love%20Python%20%26%20Java%21 before appending it to the API endpoint.
Digital Marketing and SEO
Marketers use UTM parameters to track campaigns (e.g., ?utm_source=facebook&utm_campaign=spring_sale). If a campaign name has spaces or special characters, it must be URL encoded. If a marketer wants to share a URL as a parameter inside another URL (deep linking), they must double-encode the URL to prevent the browser from misinterpreting the structure.
Data Scraping and Parsing
Data analysts who scrape websites often encounter encoded URLs in the HTML source code. They use the decode function to turn https%3A%2F%2Fexample.com back into https://example.com so it can be properly analyzed or clicked.
Database Management
Sometimes, databases store URL-encoded strings to prevent SQL injection or formatting issues. Database administrators use this tool to decode the strings when extracting reports.
Advantages of URL Encoding
Encoding URLs is not just a best practice; it is a requirement for a functional internet.
- Prevents Broken Links: Ensures spaces and special characters don’t prematurely end a URL string.
- Maintains Data Integrity: Guarantees that the server receives the exact data the user intended to send.
- Global Compatibility: Allows non-English characters (like Chinese, Arabic, or Cyrillic) to be safely transmitted using standard ASCII.
- Avoids Security Vulnerabilities: Properly encoding parameters prevents cross-site scripting (XSS) attacks and URL manipulation.
Limitations of the Calculator
While our tool is highly effective, it is important to understand its limitations:
- Does Not Encrypt Data: URL encoding is not encryption. It is just a translation of characters. Do not use it to hide sensitive data like passwords, as encoded strings are easily decoded.
- Cannot Fix Malformed URLs: If your URL is structurally broken (e.g., missing the
https://protocol entirely), encoding the string will not make it a valid link. - Requires Context for
+vs%20: The tool relies on the user to know whether the data came from an HTML form (+for space) or a standard URL (%20for space).
Tips for Accurate Results
To get the most out of the URL Encode / Decode calculator, keep these tips in mind:
- Know Your Goal: Are you encoding a whole link or just a search term? If it’s a whole link, uncheck “encodeURIComponent” or use “encodeURI” logic.
- Double-Check Emojis: Emojis take up 4 bytes and result in very long encoded strings (e.g.,
%F0%9F%98%80). Ensure your database or backend can handle the extra length. - Don’t Encode the Protocol: Never encode the
://inhttps://. If you do, the browser will treat it as a relative path rather than a web address. - Test in a Browser: After encoding, always copy the result into a new browser tab to ensure the link goes where you expect it to.
Common Mistakes to Avoid
Even with a tool, users frequently make these errors:
- Double Encoding: Encoding an already encoded string. For example, encoding
%20will result in%2520(because the%sign itself gets encoded to%25). Always decode first if you are unsure. - Mixing Form and URL Standards: Forgetting to check the “Treat
+as space” box when decoding URL parameters that came from an HTML<form>submission. - Encoding the Wrong Part: Encoding the entire URL
https://example.com/?q=testinstead of just the parametertest. - Ignoring Case Sensitivity: Hex codes are technically case-insensitive, but best practice dictates using uppercase (e.g.,
%3Dinstead of%3d).
Frequently Asked Questions (FAQs)
What is URL encoding?
URL encoding is a process that converts characters—especially spaces, symbols, and non-English text—into a universally accepted ASCII format for safe transmission over the internet. It replaces unsafe characters with a % symbol followed by a two-digit hexadecimal code.
What is the difference between encodeURI and encodeURIComponent?
encodeURI is used to encode a complete, full URL. It leaves structural characters like ://, ?, and & alone. encodeURIComponent is used to encode individual pieces of a URL (like a search query). It encodes everything, including & and =, to ensure they are treated as text rather than URL structure.
What does %20 mean in a URL?
%20 is the URL-encoded representation of a space character. Because URLs cannot contain physical spaces, the space character’s ASCII byte value (32, which is 20 in hexadecimal) is prefixed with a percent sign.
Why do some URLs use + instead of %20 for spaces?
This happens due to a historical standard called application/x-www-form-urlencoded. When data is submitted via an HTML form (like a contact form or search box), spaces are often encoded as + signs. In standard URL paths, spaces should be %20. Our tool has an option to handle both correctly.
Is URL encoding the same as Base64 encoding?
No. URL encoding makes text safe for web addresses by using % and hex values. Base64 encoding converts binary data into an ASCII string using a 64-character set, typically used for embedding images in HTML or sending file attachments. Try our Base64 Encode/Decode Calculator for that specific task.
Can I encode a URL twice?
Yes, but you shouldn’t unless you are doing “double encoding” for a specific redirect scenario. If you encode hello%20world, the % sign will be encoded into %25, resulting in hello%2520world. This usually causes errors if done accidentally.
How does URL encoding handle emojis?
Emojis are multi-byte UTF-8 characters. Because they are not standard ASCII, every single byte of the emoji is percent-encoded. For example, the simple smiley face 😊 becomes %F0%9F%98%8A (four bytes long).
Is URL encoding secure? Can it hide data?
No, URL encoding is not a security measure. It is easily recognizable by any computer system and can be decoded instantly. You should never use URL encoding to hide passwords, API keys, or sensitive personal data. Use proper encryption for security.
What does %2F mean in a URL?
%2F is the encoded version of the forward slash (/). Because / is used to separate folders and paths in a URL, if you need to include a literal / inside a search query parameter, it must be encoded as %2F.
How do I fix a broken URL link?
If a URL is broken because it contains spaces or special characters, paste it into our calculator, select “Encode”, and copy the result. If a URL looks messy with %20 and %26 everywhere, paste it in, select “Decode”, and hit enter to see the clean, readable text.
Does capitalization matter in URL encoding?
Technically, no. %3D and %3d both decode to an equals sign (=). However, uppercase hexadecimal letters are the standard convention and are considered a best practice for readability and consistency.
What happens if I don’t encode a URL?
If you don’t encode special characters, the web browser or server will likely misinterpret them. For example, if you have a space in your URL, the browser might truncate the URL at the space, resulting in a “Page Not Found” (404) error.
What is an unreserved character in a URL?
Unreserved characters are letters (A-Z, a-z), digits (0-9), and a few special symbols (-, _, ., ~). These characters never need to be encoded because they have no special meaning in URL syntax.
Can URL encoding help with SEO?
Yes. Clean, decoded URLs are better for user experience and SEO. However, when passing tracking parameters (like UTMs), proper URL encoding ensures the tracking software reads the parameters correctly, which is vital for marketing analytics.
How do I decode a URL string in JavaScript?
In JavaScript, you can use the built-in decodeURIComponent('your%20string') function to decode a URL parameter. However, using our Calculators4All.com URL tool is much faster for one-off tasks without writing code.
Why is my URL still broken after encoding?
If your URL is still broken, you likely encoded the entire URL string when you should have only encoded the parameter values. Try decoding it, separating the base URL from the parameters, and encoding only the parameters.
Related Calculators
If you found the URL Encode / Decode tool helpful, you might benefit from these other technical and formatting tools available on Calculators4All.com:
- HTML Encode / Decode: Convert text into HTML entities to prevent rendering issues on web pages.
- Base64 Encode / Decode: Encode binary data or text into a Base64 string format.
- JSON Formatter and Validator: Beautify, minify, and validate complex JSON data structures.
- Password Generator: Create strong, secure, and random passwords for your online accounts.
- MD5 Hash Generator: Generate an MD5 hash from any text string for checksum verification.
- Hex to Decimal Converter: Understand the hexadecimal codes used in URL encoding.
- Character Counter: Count the exact number of characters, words, and bytes in your string.
- QR Code Generator: Turn your safe, encoded URLs into scannable QR codes.
Final Thoughts
Understanding URL encoding is a vital skill for anyone who works with the web. Whether you are debugging an API, setting up marketing tracking, or simply trying to share a link with a friend that has an unusual character in it, percent-encoding is the bridge between human language and computer syntax.
Our URL Encode / Decode Calculator takes the guesswork out of this process. With its instant, secure, and private browser-based processing, you can trust that your links will work flawlessly every time.
Ready to fix your links? Scroll back up to the top of this page, paste your text into the input box, and see the magic happen instantly. For more tools to simplify your technical tasks, explore our full library of calculators at Calculators4All.com.