← Back to Blog

URL Encoder/Decoder: Percent Encoding Explained

URL Encoder Decoder: Handle Special Characters Like a Pro

Last updated: 2026-03-08

Target keyword: url encoder decoder online

---

Introduction

Working with URLs that contain special characters? Need to safely transmit data in query parameters? A URL encoder decoder is an essential tool for every web developer.

In this guide, we'll cover everything you need to know about URL encoding, when to use it, how it works, and the best free online tools to handle your encoding needs.

---

What is URL Encoding?

URL encoding (also called percent-encoding) is a method of encoding special characters in URLs so they can be safely transmitted over the internet.

Why URL Encoding is Necessary

URLs can only contain certain ASCII characters. Characters like spaces, ampersands, and non-English characters must be encoded.

| Character | Problem | Encoded Form | |-----------|---------|--------------| | Space | Not allowed in URLs | %20 or + | | & | Reserved for query params | %26 | | = | Reserved for key=value | %3D | | ? | Marks query string start | %3F | | / | Path separator | %2F | | # | Fragment identifier | %23 | | % | Encoding prefix | %25 |

---

How URL Encoding Works

URL encoding replaces unsafe characters with a % followed by two hexadecimal digits representing the character's ASCII value.

Examples

Original: Hello World!
Encoded:  Hello%20World%21

Original: name=John&city=New York Encoded: name%3DJohn%26city%3DNew%20York

Original: [email protected] Encoded: test%40example.com

Character Categories

Safe Characters (no encoding needed):

  • Letters: A-Z, a-z
  • Numbers: 0-9
  • Special: -, _, ., ~
Unsafe Characters (must encode):
  • Space and control characters
  • Reserved: :, /, ?, #, [, ], @
  • Delimiters: !, $, &, ', (, ), *, +, ,, ;, =
---

URL Encoding vs HTML Encoding

Don't confuse URL encoding with HTML entity encoding:

| Context | Encoding | Example | |---------|----------|---------| | URLs | %20 | hello%20world | | HTML | or   | hello world |

Use URL encoding for URLs, HTML encoding for HTML content.

---

Practical Use Cases

Use Case 1: Query Parameters

// Without encoding (BROKEN)
https://api.example.com/search?q=hello world&sort=asc

// With encoding (WORKS) https://api.example.com/search?q=hello%20world&sort=asc

Use Case 2: Redirect URLs

// Redirect parameter
https://example.com/login?redirect=https%3A%2F%2Fexample.com%2Fdashboard

Use Case 3: File Paths

// File with special characters
https://cdn.example.com/files/my%20document%20(v2).pdf

Use Case 4: Non-ASCII Characters

// Chinese characters
Original: 你好世界
Encoded: %E4%BD%A0%E5%A5%BD%E4%B8%96%E7%95%8C

// Emoji Original: 👍 Encoded: %F0%9F%91%8D

---

URL Decoding: Reversing the Process

Decoding converts percent-encoded characters back to their original form.

Example

Encoded:  https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Dhello%2520world
Decoded:  https://example.com/search?q=hello%20world

Notice the double encoding - sometimes URLs are encoded multiple times.

---

How to Encode/Decode URLs Online

Using DevKits URL Encoder

1. Navigate to Tool - Visit URL Encoder 2. Enter Text - Paste your URL or text 3. Auto Encode/Decode - Tool detects and converts automatically 4. Copy Result - One-click copy to clipboard

Features to Look For

  • ✅ Automatic detection (encode or decode)
  • ✅ Real-time conversion
  • ✅ Handle double-encoded URLs
  • ✅ Preserve already-encoded sequences
  • ✅ Client-side processing for privacy
---

URL Encoding in Programming

JavaScript

// Encode
const encoded = encodeURIComponent('Hello World!');
console.log(encoded); // Hello%20World%21

// Decode const decoded = decodeURIComponent('Hello%20World%21'); console.log(decoded); // Hello World!

// For full URLs (preserves protocol, etc.) const url = 'https://example.com/path?query=hello world'; const encodedUrl = encodeURI(url);

Python

from urllib.parse import quote, unquote, quote_plus

Encode

encoded = quote('Hello World!') print(encoded) # Hello%20World%21

Decode

decoded = unquote('Hello%20World%21') print(decoded) # Hello World!

For query strings (space becomes +)

query_encoded = quote_plus('Hello World') print(query_encoded) # Hello+World

PHP

// Encode
$encoded = urlencode('Hello World!');
echo $encoded; // Hello%20World%21

// Decode $decoded = urldecode('Hello%20World%21'); echo $decoded; // Hello World!

// For query strings $query = http_build_query(['name' => 'John Doe']); // name=John+Doe

Java

import java.net.URLEncoder;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;

// Encode String encoded = URLEncoder.encode("Hello World!", StandardCharsets.UTF_8);

// Decode String decoded = URLDecoder.decode("Hello%20World%21", StandardCharsets.UTF_8);

---

Common URL Encoding Mistakes

Mistake 1: Double Encoding

// Wrong - encoding already encoded string
Original:  hello%20world
Encoded:   hello%2520world (WRONG!)

// Correct - decode first, then encode if needed

Mistake 2: Encoding the Entire URL

// Wrong - encodes everything including protocol
https%3A%2F%2Fexample.com%2Fpath

// Correct - only encode specific parts https://example.com/path%20with%20spaces

Mistake 3: Using Wrong Encoding for Context

// Wrong - HTML encoding in URL
hello world (HTML entity, not URL encoding)

// Correct hello%20world

---

Try DevKits URL Encoder

Need to encode or decode URLs instantly? Try our free URL Encoder:

  • ✅ Automatic encode/decode detection
  • ✅ Real-time conversion
  • ✅ Handle special characters and emoji
  • ✅ 100% client-side processing
  • ✅ No signup required
  • ✅ Copy to clipboard with one click
---

Frequently Asked Questions

Q: What's the difference between encodeURI and encodeURIComponent?

A: encodeURI encodes a complete URL and preserves characters like :, /, ?. encodeURIComponent encodes individual components and escapes all special characters.

Q: Why are spaces encoded as + in query strings?

A: This is legacy behavior from application/x-www-form-urlencoded. Both %20 and + represent spaces in query strings.

Q: Do I need to encode numbers and letters?

A: No. Alphanumeric characters (A-Z, a-z, 0-9) are safe in URLs and don't need encoding.

Q: What about non-English characters?

A: Non-ASCII characters must be UTF-8 encoded first, then percent-encoded. For example, ñ becomes %C3%B1.

Q: Can I manually decode URLs without a tool?

A: For simple cases, yes. Look up ASCII codes for hex values. But for complex or double-encoded URLs, use a tool.

---

Conclusion

A URL encoder decoder is an essential tool for web developers working with URLs, APIs, and query parameters. Understanding when and how to encode URLs prevents bugs and ensures your data is transmitted correctly.

Key takeaways:

  • URL encoding replaces special characters with % + hex code
  • Only encode URL components, not entire URLs
  • Use encodeURIComponent for query parameter values
  • Never confuse URL encoding with HTML encoding
Need to encode a URL? Try our free URL Encoder — instant, private, and works entirely in your browser.

---

Related Tools:

Try This Tool Free

DevKits offers this tool 100% free, no signup required:

  • Runs entirely in your browser (client-side)
  • No data is sent to servers (privacy-first)
  • Works offline (PWA enabled)
  • No usage limits
Use URL Encoder →