Advertisement

URL Encoder & Decoder

Encode special characters for safe URL usage or decode percent-encoded URL strings back to readable text.

Input
Try an example:
Ctrl+Enter
Advertisement
Output

What is URL Encoder & Decoder?

URL encoding (also known as percent-encoding) is a mechanism for converting special characters into a format that can be safely transmitted over the internet. Characters like spaces, ampersands, question marks, and non-ASCII characters are replaced with a percent sign followed by two hexadecimal digits. There are two main types: encodeURI for full URLs (preserving URL structure characters like /, ?, &) and encodeURIComponent for individual URL parameter values (encoding all special characters).

How to Use This URL Encoder & Decoder

Enter your text or URL in the input field. Click "Encode URL" to safely encode a full URL while preserving its structure. Click "Encode Component" to encode individual parameter values (more aggressive encoding). To decode, paste a percent-encoded string and click "Decode URL" to see the original text.

Why Use This URL Encoder & Decoder?

Our URL encoder is essential for web developers building query strings, API requests, or handling user input in URLs. It handles all edge cases correctly and runs entirely in your browser. No data is uploaded to any server, ensuring complete privacy. Perfect for debugging encoded URLs, constructing safe links, or understanding percent-encoded data.

Common Use Cases

URL encoding is a fundamental skill for anyone working with the web. Here are the most common practical scenarios where this tool is essential:

  • Building Query Strings: When constructing URLs with query parameters, special characters like spaces, ampersands, and equals signs must be encoded. For example, a search for "cats & dogs" becomes ?q=cats%20%26%20dogs. This tool lets you encode each parameter value safely.
  • Processing Form Submissions: HTML forms use URL encoding by default (application/x-www-form-urlencoded) when submitted via GET or POST. Understanding how form data is encoded helps when debugging form submissions or building server-side handlers.
  • API Parameter Construction: REST APIs often receive parameters in the URL path or query string. Special characters in path segments or parameter values must be properly encoded. Using encodeURIComponent ensures your API calls are correctly formed and not rejected by the server.
  • Debugging Encoded URLs: When you encounter a long percent-encoded URL in logs, analytics, or error messages, this tool helps you decode it back to human-readable text, making it much easier to understand what the URL was actually requesting.

Tips & Best Practices

  • Understand encodeURI vs encodeURIComponent: encodeURI encodes a full URI while preserving characters that are part of the URI syntax (/, ?, &, #). Use this for encoding entire URLs. encodeURIComponent encodes everything, including those characters — use this for individual query parameter values. Using the wrong one is a common source of bugs.
  • Always encode user input: Any text input from users that becomes part of a URL should be encoded. Failure to do so can cause broken links, incorrect API calls, or even security vulnerabilities. Never assume user input is safe for URLs.
  • Remember that spaces encode to %20: In URL encoding, a space is represented as %20. Some older implementations use + for spaces in query strings (application/x-www-form-urlencoded), but %20 is the standard and works everywhere including path segments.
  • Decode before displaying: If you are showing URLs to users in a user interface, always decode percent-encoded strings first. Displaying raw %20 or %26 looks unprofessional and confuses users.
  • Watch for double encoding: If a URL parameter appears encoded when you receive it and you encode it again, the % signs get encoded to %25, producing %2520 instead of %20. Only encode the original unencoded value, not an already-encoded string.

URL Encoding Quick Reference

CharacterEncoded FormCommon Context
Space%20Query strings, path segments
! Exclamation mark%21Path segments, parameter values
# Hash%23Fragment identifiers
$ Dollar sign%24Parameter values
% Percent%25Already-encoded values
& Ampersand%26Query parameter separators
+ Plus%2BParameter values, form data
/ Slash%2FPath segments (when not a separator)
= Equals%3DKey-value pairs in query strings
? Question mark%3FQuery string start

Frequently Asked Questions

What is the difference between URL encoding and HTML encoding?

URL encoding (percent-encoding) converts characters for safe transmission in URLs by replacing them with % followed by two hexadecimal digits. HTML encoding uses named or numeric character entities like & to display reserved characters in HTML content. They serve different purposes and should not be confused.

When should I use encodeURI versus encodeURIComponent?

Use encodeURI when you have a complete URL string and want to encode special characters while keeping the URL functional (it preserves /, ?, &, #). Use encodeURIComponent when encoding individual query parameter values — it encodes all special characters, ensuring the value does not break the URL structure.

Why is my encoded URL not working?

Common reasons include double encoding (encoding an already-encoded string), using encodeURI instead of encodeURIComponent for parameter values, or forgetting to encode the value at all. Try decoding your URL fully first, then encode each component separately using the appropriate method.

Does this tool support Unicode characters?

Yes. URL encoding converts non-ASCII characters to their UTF-8 byte sequences and then percent-encodes each byte. For example, the Euro sign (EUR) encodes to %E2%82%AC. This tool handles Unicode characters correctly on both encode and decode operations.

Advertisement