-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathurl-encoder.html
More file actions
469 lines (445 loc) · 24.9 KB
/
url-encoder.html
File metadata and controls
469 lines (445 loc) · 24.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-4PBF3H18LT"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-4PBF3H18LT');
</script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>URL Encoder / Decoder - Online Free URL Converter Tool</title>
<meta name="description" content="Free online URL encoder and decoder tool. Encode and decode URLs instantly for safe web transmission. Supports UTF-8 characters and special symbols.">
<link rel="canonical" href="https://binary-code-translator.com/url-encoder.html">
<!-- Open Graph Meta Tags -->
<meta property="og:title" content="URL Encoder / Decoder - Online Free URL Converter Tool">
<meta property="og:description" content="Free online URL encoder and decoder tool. Encode and decode URLs instantly for safe web transmission.">
<meta property="og:type" content="website">
<meta property="og:url" content="https://binary-code-translator.com/url-encoder.html">
<!-- Twitter Card Meta Tags -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="URL Encoder / Decoder - Online Free URL Converter Tool">
<meta name="twitter:description" content="Free online URL encoder and decoder tool. Encode and decode URLs instantly for safe web transmission.">
<!-- Structured Data -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebApplication",
"name": "URL Encoder / Decoder",
"description": "Free online tool to encode URLs for safe transmission and decode URL-encoded strings back to original text",
"url": "https://binary-code-translator.com/url-encoder.html",
"applicationCategory": "DeveloperApplication",
"operatingSystem": "Any",
"offers": {
"@type": "Offer",
"price": "0",
"priceCurrency": "USD"
}
}
</script>
<link rel="stylesheet" href="css/style.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
</head>
<body data-mode="url">
<header>
<div class="container">
<div class="nav-wrapper">
<div class="logo">
<h1><a href="index.html">Binary Code Translator</a></h1>
<div class="tagline">Professional URL Encoder & Decoder - Free Online Tool</div>
</div>
<button class="mobile-menu-toggle" id="mobileMenuToggle">☰</button>
<nav>
<ul>
<li><a href="index.html">Binary Translator</a></li>
<li>
<a href="#" onclick="return false;">
Number Base Converters
<span class="dropdown-arrow"></span>
</a>
<div class="dropdown">
<div class="dropdown-item">
<div class="dropdown-category">Binary Converters</div>
<a href="binary-to-decimal.html">Binary ↔ Decimal</a>
<a href="binary-to-hex.html">Binary ↔ Hexadecimal</a>
</div>
<div class="dropdown-item">
<div class="dropdown-category">Multi-Base Converters</div>
<a href="base-converter.html">Base 2-62 Converter</a>
</div>
</div>
</li>
<li>
<a href="#" onclick="return false;" class="active">
Developer Tools
<span class="dropdown-arrow"></span>
</a>
<div class="dropdown">
<div class="dropdown-item">
<div class="dropdown-category">Encoding</div>
<a href="base64-encoder.html">Base64 Encoder/Decoder</a>
<a href="url-encoder.html" class="active">URL Encoder/Decoder</a>
</div>
</div>
</li>
<li><a href="blog/index.html">Blog</a></li>
</ul>
</nav>
</div>
</div>
</header>
<main class="container">
<section class="converter-section">
<div class="converter-box">
<div class="converter-header">
<h2>URL Encoder and Decoder</h2>
<div class="quick-actions">
<button id="btnHistory" class="btn btn-icon" title="View History" aria-label="View Conversion History">📜</button>
</div>
</div>
<div class="input-group">
<div class="label-container">
<label for="inputLeft">
<span class="label-icon">📝</span>
<span class="label-text">Input Text / URL</span>
</label>
<div class="stats-container">
<span class="char-count" id="charCountLeft">0 chars</span>
<span class="word-count" id="wordCountLeft">0 words</span>
<span class="line-count" id="lineCountLeft">0 lines</span>
</div>
</div>
<div class="input-wrapper">
<textarea id="inputLeft" placeholder="Type or paste URL/text here to encode or decode... Example: https://example.com/search?q=hello world" autofocus></textarea>
<div id="dragOverlay" class="drag-overlay">
📁 Drop file here to convert
</div>
</div>
<div class="input-actions">
<button class="btn btn-copy" data-target="inputLeft">
<span class="btn-icon">📋</span> Copy
</button>
<button class="btn btn-paste" onclick="navigator.clipboard.readText().then(text => document.getElementById('inputLeft').value = text)">
<span class="btn-icon">📥</span> Paste
</button>
<button class="btn btn-clear" onclick="document.getElementById('inputLeft').value = ''; document.getElementById('inputRight').value = '';">
<span class="btn-icon">🗑️</span> Clear
</button>
</div>
</div>
<div class="controls" style="display:flex; gap:1rem; justify-content:center; margin: 1.5rem 0;">
<button class="btn btn-primary" onclick="encodeURL()">
<span class="btn-icon">🔒</span> Encode (Text → URL)
</button>
<button id="btnSwap" class="btn btn-icon" title="Swap Input/Output" aria-label="Swap Input and Output" style="margin: 0 0.5rem;">⇄</button>
<button class="btn btn-primary" onclick="decodeURL()">
<span class="btn-icon">🔓</span> Decode (URL → Text)
</button>
</div>
<div class="input-group">
<div class="label-container">
<label for="inputRight">
<span class="label-icon">✅</span>
<span class="label-text">Result</span>
</label>
<div class="stats-container">
<span class="char-count" id="charCountRight">0 chars</span>
<span class="word-count" id="wordCountRight">0 words</span>
<span class="line-count" id="lineCountRight">0 lines</span>
</div>
</div>
<div class="input-wrapper">
<textarea id="inputRight" readonly placeholder="Result will appear here..."></textarea>
</div>
<div class="output-actions">
<button class="btn btn-copy" data-target="inputRight">
<span class="btn-icon">📋</span> Copy Result
</button>
<button id="btnDownload" class="btn">
<span class="btn-icon">💾</span> Download
</button>
</div>
</div>
<div id="errorMsg" class="error-msg"></div>
</div>
</section>
<!-- Features Section -->
<section class="features-section collapsible-section">
<div class="section-header" data-target="features">
<h2 class="section-title">Key Features</h2>
<span class="section-toggle">▼</span>
</div>
<div class="section-content" id="features">
<div class="features-grid">
<div class="feature-card">
<div class="feature-icon">⚡</div>
<h3>Instant Conversion</h3>
<p>Encode and decode URLs instantly. No waiting, no page reloads.</p>
</div>
<div class="feature-card">
<div class="feature-icon">🌍</div>
<h3>UTF-8 Support</h3>
<p>Fully supports UTF-8 characters, including emojis and international text.</p>
</div>
<div class="feature-card">
<div class="feature-icon">🔒</div>
<h3>Secure & Private</h3>
<p>All conversions happen locally in your browser. Your data never leaves your device.</p>
</div>
<div class="feature-card">
<div class="feature-icon">🔗</div>
<h3>Full URL Encoding</h3>
<p>Properly encodes all special characters including spaces, symbols, and non-ASCII characters.</p>
</div>
<div class="feature-card">
<div class="feature-icon">📋</div>
<h3>One-Click Copy</h3>
<p>Easily copy results to clipboard with a single click for quick use in your projects.</p>
</div>
<div class="feature-card">
<div class="feature-icon">💾</div>
<h3>History Tracking</h3>
<p>Automatically saves your recent conversions for quick reference and reuse.</p>
</div>
</div>
</div>
</section>
<!-- Examples Section -->
<section class="examples-section collapsible-section">
<div class="section-header" data-target="examples">
<h2 class="section-title">URL Encoding Examples</h2>
<span class="section-toggle">▼</span>
</div>
<div class="section-content" id="examples">
<div class="examples-grid">
<div class="example-item">
<div class="example-preview">hello world</div>
<div class="example-code">hello%20world</div>
<button class="btn btn-example" data-text="hello world">Try it</button>
</div>
<div class="example-item">
<div class="example-preview">user@example.com</div>
<div class="example-code">user%40example.com</div>
<button class="btn btn-example" data-text="user@example.com">Try it</button>
</div>
<div class="example-item">
<div class="example-preview">100% Complete</div>
<div class="example-code">100%25%20Complete</div>
<button class="btn btn-example" data-text="100% Complete">Try it</button>
</div>
<div class="example-item">
<div class="example-preview">https://site.com/?q=test&lang=en</div>
<div class="example-code">https%3A%2F%2Fsite.com%2F%3Fq%3Dtest%26lang%3Den</div>
<button class="btn btn-example" data-text="https://site.com/?q=test&lang=en">Try it</button>
</div>
<div class="example-item">
<div class="example-preview">你好世界</div>
<div class="example-code">%E4%BD%A0%E5%A5%BD%E4%B8%96%E7%95%8C</div>
<button class="btn btn-example" data-text="你好世界">Try it</button>
</div>
<div class="example-item">
<div class="example-preview">🔒 Secure</div>
<div class="example-code">%F0%9F%94%92%20Secure</div>
<button class="btn btn-example" data-text="🔒 Secure">Try it</button>
</div>
</div>
</div>
</section>
<!-- Educational Content -->
<section class="educational-section collapsible-section">
<div class="section-header" data-target="educational">
<h2 class="section-title">About URL Encoding</h2>
<span class="section-toggle">▼</span>
</div>
<div class="section-content" id="educational">
<div class="educational-content">
<div class="edu-text">
<h3>What is URL Encoding?</h3>
<p>URL encoding (also known as percent-encoding) is a mechanism for encoding information in a Uniform Resource Identifier (URI) under certain circumstances. It converts unsafe ASCII characters into a format that can be transmitted over the Internet.</p>
<h3>Why Use URL Encoding?</h3>
<p>URL encoding is commonly used in:</p>
<ul>
<li><strong>Query Parameters:</strong> Passing data in URL query strings safely.</li>
<li><strong>Form Data:</strong> Encoding form submissions for GET requests.</li>
<li><strong>API Requests:</strong> Transmitting special characters in API endpoints.</li>
<li><strong>File Paths:</strong> Encoding file names and paths in URLs.</li>
</ul>
<h3>How URL Encoding Works</h3>
<p>URL encoding replaces unsafe ASCII characters with a "%" followed by two hexadecimal digits. For example, a space is encoded as "%20", and an "@" symbol becomes "%40". Non-ASCII characters are first converted to UTF-8 bytes, then each byte is percent-encoded.</p>
<h3>Common Encoded Characters</h3>
<div class="binary-table">
<h4>URL Encoding Reference Table</h4>
<div class="table-wrapper">
<table>
<tr><th>Character</th><th>Encoded</th><th>Description</th></tr>
<tr><td>space</td><td>%20</td><td>Space character</td></tr>
<tr><td>!</td><td>%21</td><td>Exclamation mark</td></tr>
<tr><td>@</td><td>%40</td><td>At symbol</td></tr>
<tr><td>#</td><td>%23</td><td>Hash/Number sign</td></tr>
<tr><td>$</td><td>%24</td><td>Dollar sign</td></tr>
<tr><td>%</td><td>%25</td><td>Percent sign</td></tr>
<tr><td>&</td><td>%26</td><td>Ampersand</td></tr>
<tr><td>/</td><td>%2F</td><td>Forward slash</td></tr>
<tr><td>=</td><td>%3D</td><td>Equals sign</td></tr>
<tr><td>?</td><td>%3F</td><td>Question mark</td></tr>
</table>
</div>
</div>
<h3>How to Use This Tool</h3>
<ol>
<li><strong>To Encode:</strong> Type or paste your URL or text into the input box and click "Encode".</li>
<li><strong>To Decode:</strong> Paste a URL-encoded string and click "Decode".</li>
<li><strong>Copy Result:</strong> Click "Copy Result" to copy the output to your clipboard.</li>
</ol>
</div>
</div>
</div>
</section>
<!-- FAQ Section -->
<section class="faq-section collapsible-section">
<div class="section-header" data-target="faq">
<h2 class="section-title">Frequently Asked Questions</h2>
<span class="section-toggle">▼</span>
</div>
<div class="section-content" id="faq">
<div class="faq-container">
<div class="faq-item">
<div class="faq-question">
<h3>What is the difference between encodeURI() and encodeURIComponent()?</h3>
<span class="faq-toggle">+</span>
</div>
<div class="faq-answer">
<p><strong>encodeURI()</strong> encodes a complete URI but leaves characters like :/?#=@& intact since they have special meaning in URLs. <strong>encodeURIComponent()</strong> encodes all special characters including these, making it suitable for encoding individual query parameters or URL components. This tool uses encodeURIComponent() for full encoding capability.</p>
</div>
</div>
<div class="faq-item">
<div class="faq-question">
<h3>Why are spaces encoded as %20 instead of +?</h3>
<span class="faq-toggle">+</span>
</div>
<div class="faq-answer">
<p>Both %20 and + are used to encode spaces in URLs. %20 is the standard percent-encoding for spaces. The + sign is used in application/x-www-form-urlencoded data (like form submissions). This tool uses %20 which is more universally compatible with modern URL standards.</p>
</div>
</div>
<div class="faq-item">
<div class="faq-question">
<h3>How are non-ASCII characters encoded?</h3>
<span class="faq-toggle">+</span>
</div>
<div class="faq-answer">
<p>Non-ASCII characters (like emojis or Chinese text) are first converted to UTF-8 byte sequences. Each byte is then percent-encoded. For example, "你好" becomes "%E4%BD%A0%E5%A5%BD" - each %XX represents one byte of the UTF-8 encoding.</p>
</div>
</div>
<div class="faq-item">
<div class="faq-question">
<h3>Is URL encoding encryption?</h3>
<span class="faq-toggle">+</span>
</div>
<div class="faq-answer">
<p>No, URL encoding is not encryption. It is simply a way to represent special characters safely in URLs. Anyone can decode a URL-encoded string. It does not provide any security or data protection - it only ensures safe data transmission through URLs.</p>
</div>
</div>
<div class="faq-item">
<div class="faq-question">
<h3>When should I use URL encoding?</h3>
<span class="faq-toggle">+</span>
</div>
<div class="faq-answer">
<p>Use URL encoding whenever you need to include user input or special characters in a URL. This includes query parameters, form data in GET requests, API endpoints, and any time you're constructing URLs dynamically. Failing to encode properly can result in broken URLs or security vulnerabilities.</p>
</div>
</div>
</div>
</div>
</section>
</main>
<!-- History Modal -->
<div id="historyModal" class="modal" style="display: none;">
<div class="modal-content">
<div class="modal-header">
<h2>Conversion History</h2>
<div class="modal-header-actions">
<button id="clearHistory" class="btn btn-danger btn-sm">Clear History</button>
<button class="modal-close" id="closeHistory">×</button>
</div>
</div>
<div class="modal-body">
<div id="historyList" class="history-list">
<p class="no-history">No conversion history yet</p>
</div>
</div>
</div>
</div>
<footer>
<div class="container">
<div class="footer-content">
<div class="footer-section">
<h3>Binary Code Translator</h3>
<p>Free online tool to translate text to binary and binary to text. Fast, secure, and easy to use.</p>
</div>
<div class="footer-section">
<h4>Tools</h4>
<ul>
<li><a href="index.html">Binary Translator</a></li>
<li><a href="binary-to-decimal.html">Binary to Decimal</a></li>
<li><a href="binary-to-hex.html">Binary to Hex</a></li>
<li><a href="base64-encoder.html">Base64 Encoder</a></li>
<li><a href="url-encoder.html">URL Encoder</a></li>
</ul>
</div>
<div class="footer-section">
<h4>Legal</h4>
<ul>
<li><a href="legal/privacy.html">Privacy Policy</a></li>
<li><a href="legal/terms.html">Terms of Service</a></li>
</ul>
</div>
</div>
<div class="footer-bottom">
<p>© 2025 Binary Code Translator. All rights reserved.</p>
</div>
</div>
</footer>
<!-- Reusing UI controller for collapsible sections and copy functionality -->
<script src="js/ui-controller.js"></script>
<script src="js/enhanced-ui.js"></script>
<script>
// Define Converter object for URL encoding/decoding
window.Converter = {
detectInputType: function(input) {
if (!input) return 'empty';
// Simple heuristic: If it contains %XX patterns, assume URL-encoded
if (/%[0-9A-Fa-f]{2}/.test(input)) return 'url-encoded';
return 'text';
},
textToEncoded: function(input) {
try {
return encodeURIComponent(input);
} catch (e) { return "Error: Unable to encode"; }
},
encodedToText: function(input) {
try {
return decodeURIComponent(input);
} catch (e) { return "Error: Invalid URL-encoded string"; }
}
};
// Manual button functions
function encodeURL() {
const input = document.getElementById('inputLeft').value;
if (!input) return;
const result = Converter.textToEncoded(input);
document.getElementById('inputRight').value = result;
}
function decodeURL() {
const input = document.getElementById('inputLeft').value;
if (!input) return;
const result = Converter.encodedToText(input);
document.getElementById('inputRight').value = result;
}
</script>
</body>
</html>