URL Encoder & Decoder

Encode and decode URLs with advanced features

Mode

Options

Quick Actions

History

Text to Encode

Private

All encoding happens in your browser. No data sent to servers.

Instant

Real-time encoding and decoding with instant results.

Standards

Uses standard URL encoding (RFC 3986) for compatibility.

Private

All encoding happens in your browser. No data sent to servers.

Instant

Real-time encoding and decoding with instant results.

Standards

Uses standard URL encoding (RFC 3986) for compatibility.

What is URL Encoding?

URL encoding converts characters into a format that can be transmitted over the Internet. Special characters are replaced with a % followed by two hexadecimal digits.

Common Encodings:

  • Space → %20
  • ! → %21
  • # → %23
  • & → %26

Use Cases:

  • • Passing parameters in URLs
  • • Encoding search queries
  • • API request formatting
  • • Form data submission

The Complete Guide to URL Encoding: Encode, Decode, and Understand URLs

URL encoding (also called percent encoding) is essential for web development, API integration, and data transmission. Our free URL encoder and decoder tool helps you encode special characters, decode URL-encoded strings, and understand how URLs handle non-alphanumeric characters. Whether you're building APIs, debugging query parameters, or formatting search queries, mastering URL encoding ensures your web applications handle data correctly.

What is URL Encoding and Why Is It Necessary?

URL encoding converts characters that aren't allowed in URLs into a format that can be transmitted safely over the internet. URLs can only contain a limited set of ASCII characters - letters, numbers, and a few special characters like hyphen (-) and underscore (_). Any other characters must be encoded.

The encoding format uses a percent sign (%) followed by two hexadecimal digits representing the character's ASCII code. For example, a space becomes `%20`, an ampersand becomes `%26`, and a hash becomes `%23`. This encoding ensures that URLs work consistently across all browsers, servers, and network infrastructure.

Characters That Need URL Encoding

Reserved Characters: These have special meaning in URLs and must be encoded when used literally:

  • Ampersand (&): Separates query parameters, encode as `%26`
  • Equal Sign (=): Separates parameter names from values, encode as `%3D`
  • Question Mark (?): Starts query string, encode as `%3F`
  • Hash (#): Indicates fragments/anchors, encode as `%23`
  • Slash (/): Path separator, encode as `%2F` when used in query values
  • Plus (+): Can represent spaces in query strings, encode as `%2B` when literal
  • Percent (%): Encoding indicator itself, encode as `%25`

Unsafe Characters: Space, quotes, brackets, and non-ASCII characters always need encoding.

URL Encoding vs URI Encoding

URL Encoding: Specifically for URLs (Uniform Resource Locators). Encodes characters that aren't safe for the URL path, query string, or fragment.

URI Encoding: Broader term including URLs and URNs (Uniform Resource Names). URI encoding follows RFC 3986 standards and has slightly different rules for different URI components.

Component Encoding: Different URL parts have different encoding rules. What's safe in the path may need encoding in the query string. Our URL encoder applies appropriate encoding based on context.

Common URL Encoding Use Cases

Search Queries: When users search for "cats & dogs", the ampersand must be encoded to `%26` so it doesn't get interpreted as a query parameter separator. The search URL becomes `?q=cats%20%26%20dogs`.

API Requests: REST APIs often require URL-encoded parameters. Sending user-generated content in query parameters requires encoding special characters to prevent parsing errors or injection attacks.

Form Data: HTML forms with method="GET" automatically URL-encode form field values before submission. Understanding this encoding helps debug form submissions.

OAuth and Authentication: OAuth redirect URLs, state parameters, and callback URLs must be properly encoded to maintain integrity through multiple redirects.

Social Media Sharing: Share URLs with encoded titles, descriptions, and image URLs. Social media platforms parse these encoded parameters to populate share dialogs.

URL Encoding Best Practices

Always Encode Query Parameters: Never concatenate raw user input into URLs. Always encode parameter values using proper URL encoding functions in your programming language.

Encode Only Once: Double encoding causes errors. If you encode "hello world" twice, it becomes `hello%2520world` instead of `hello%20world`. Track whether values are already encoded.

Use Standard Functions: Don't write your own URL encoding. Use language-provided functions: `encodeURIComponent()` in JavaScript, `urllib.parse.quote()` in Python, `urlencode()` in PHP.

Decode Before Display: URL-encoded strings look ugly to users. Always decode them before displaying in UI, logs, or error messages.

Spaces in URLs: %20 vs +

%20 Encoding: The standard way to encode spaces in URLs. Works everywhere - paths, query strings, fragments. Always safe and modern browsers prefer this format.

Plus (+) Encoding: Legacy form encoding uses `+` for spaces in query strings only. This comes from `application/x-www-form-urlencoded` format. Works in query parameters but not in paths.

Best Practice: Use `%20` for consistency. Modern APIs and applications prefer percent encoding for spaces everywhere in URLs.

URL Decoding: Converting Back to Normal Text

URL decoding reverses the encoding process, converting percent-encoded characters back to their original form. Our URL decoder handles all encoding formats including `%20` spaces, `+` spaces, and UTF-8 multi-byte characters.

When to Decode: Decode URLs when logging API requests, displaying query parameters to users, processing form submissions on the server, or analyzing URL structures for debugging.

Automatic Decoding: Most web frameworks automatically decode query parameters server-side. You typically don't need to manually decode parameters in request handlers.

International Characters and UTF-8 Encoding

Unicode in URLs: Non-ASCII characters (Chinese, Arabic, Emoji, etc.) get encoded as UTF-8 bytes, then percent-encoded. "你好" becomes `%E4%BD%A0%E5%A5%BD` - each character becomes multiple percent-encoded bytes.

Punycode: For international domain names (IDN), browsers use Punycode encoding. "münchen.de" becomes "xn--mnchen-3ya.de". This is different from URL encoding and happens automatically in browsers.

Modern URLs: Modern browsers display international characters in the address bar but transmit them percent-encoded. Users see "münchen.de/café" but servers receive "xn--mnchen-3ya.de/caf%C3%A9".

URL Encoding in Different Programming Languages

JavaScript: Use `encodeURIComponent()` for query parameters and `encodeURI()` for complete URLs. Never use `escape()` - it's deprecated and doesn't handle UTF-8 correctly. `decodeURIComponent()` reverses the encoding.

Python: `urllib.parse.quote()` encodes, `urllib.parse.unquote()` decodes. Use `quote_plus()` for form-style encoding with `+` for spaces. Python 3's urllib properly handles Unicode.

PHP: `urlencode()` for form encoding (+ for spaces), `rawurlencode()` for RFC 3986 encoding (% for spaces). Use `urldecode()` or `rawurldecode()` to decode.

Java: `URLEncoder.encode()` and `URLDecoder.decode()` from `java.net` package. Always specify UTF-8 charset for consistent encoding.

C#/.NET: `HttpUtility.UrlEncode()` and `HttpUtility.UrlDecode()` from System.Web, or `Uri.EscapeDataString()` for newer applications.

Common URL Encoding Mistakes

Encoding the Entire URL: Don't encode the whole URL including `https://`. Only encode parameter values and user-generated content. The protocol, domain, and path structure should remain unencoded.

Forgetting to Encode: Passing unencoded special characters breaks URLs. `?name=John & Jane` splits into two parameters because `&` isn't encoded. Should be `?name=John%20%26%20Jane`.

Wrong Encoding Type: Using HTML entity encoding (`&`) instead of URL encoding (`%26`) in URLs. HTML and URL encoding are different.

Encoding Path Segments: Over-encoding makes URLs ugly and sometimes breaks routing. Modern web frameworks handle path encoding, so encoding manually can cause issues.

Security Considerations with URL Encoding

Injection Attacks: Improper URL encoding enables injection attacks. Always encode user input before including it in URLs to prevent attackers from injecting malicious parameters or breaking out of query strings.

Open Redirects: When using URLs in redirect parameters, validate and sanitize them even after URL encoding. Attackers can craft encoded URLs that redirect to malicious sites.

Null Byte Injection: URL-encoded null bytes (`%00`) can cause security issues in some systems. Validate decoded URLs to reject null bytes and other control characters.

Double Encoding: Attackers sometimes use double encoding to bypass security filters. Server-side validation should handle multiply-encoded input.

URL Encoding for SEO

Clean URLs: For SEO-friendly URLs, minimize encoding. Use hyphens for spaces in slugs: `"my-article-title"` instead of `"my%20article%20title"`. Search engines prefer readable URLs.

Canonical URLs: Ensure canonical URLs use consistent encoding. `"/product/café"` and `"/product/caf%C3%A9"` should canonicalize to the same URL to avoid duplicate content issues.

URL Structure: Keep paths simple and avoid excessive encoding. Good: `"/products/coffee-maker"`. Bad: `"/products/Coffee%20Maker%20%28Professional%29"`.

Testing and Debugging URL Encoding

Browser Dev Tools: Network tab shows both encoded (transmitted) and decoded (displayed) URLs. Compare them to identify encoding issues.

Online Tools: Use our URL encoder decoder to quickly encode test values and verify encoding is correct before implementing in code.

Logging: Log both encoded and decoded URLs in application logs to debug API integration issues and malformed URL problems.

Unit Tests: Write tests for URL encoding edge cases: special characters, international characters, very long strings, and already-encoded input.

Advanced URL Encoding Topics

Batch Encoding: Our tool supports batch URL encoding for processing multiple URLs or parameters simultaneously. Useful for data migration or bulk API operations.

Custom Encoding Rules: Some systems require custom encoding rules beyond standard RFC 3986. OAuth signatures, AWS request signing, and some legacy APIs have special requirements.

Encoding Validation: Validate that URL-encoded strings decode successfully. Malformed encoding (incomplete percent sequences, invalid hex digits) should trigger errors.

Start Encoding URLs Today

Whether you're building APIs, debugging web applications, formatting search queries, or processing form data, our free URL encoder and decoder helps you handle URL encoding correctly and efficiently.

The tool offers encoding and decoding in one interface, support for RFC 3986 standards, batch URL processing, space encoding options (%20 or +), UTF-8 international character support, and instant results with one click. Start encoding and decoding URLs today to build robust web applications that handle data safely and correctly.