URL Encoder and Decoder: How to Encode URLs for Links, Forms, and APIs

Have you ever clicked a link and seen a long, confusing address full of %20, %2F, and %3F? That is URL encoding (also called percent-encoding) at work. URLs can only legally contain a limited set of characters — letters, digits, and a few symbols. Everything else, including spaces, accented characters, and reserved symbols like & and ?, must be converted into a % followed by two hex digits. Getting this wrong breaks links, form submissions, and API calls with confusing “400 Bad Request” errors.

You can encode or decode any URL instantly with the free URL encoder and decoder tool. Here is how URL encoding works and where it matters.

Why URLs Need Encoding

A URL is a strict grammar, not free-form text. The characters that have special meaning — / separates path segments, ? starts the query string, & separates query parameters, = assigns values, # starts a fragment — cannot appear as literal data inside those parts. If your search term is “Q&A session”, the & would be misinterpreted as a parameter separator. Encoding it as %26 tells the server: “this is data, not syntax.”

The same applies to characters outside the ASCII set. A URL containing “café” or “日本語” must encode those characters as UTF-8 percent-encoded bytes (caf%C3%A9, %E6%97%A5%E6%9C%AC%E8%AA%9E). Browsers do this automatically in the address bar, but when you build URLs in code, in spreadsheets, or in query strings by hand, you must do it yourself.

Common Situations That Require URL Encoding

  • Search URLs: Building a link like ?q=best coffee shops requires encoding the space as %20 or +.
  • Redirect URLs: A redirect_to parameter that contains another full URL must encode its :, /, and ? characters.
  • API calls: REST API query parameters with special characters break requests unless properly encoded.
  • Form submissions: Browsers encode form data automatically, but debugging a bad submission often means checking the encoded values.
  • Tracking links: Affiliate and analytics URLs with nested parameters are notorious for breaking when inner URLs are not encoded.

How to Encode a URL

  1. Open the URL encoder tool.
  2. Paste the URL or text you need to encode.
  3. Click Encode and copy the percent-encoded result.
  4. Paste it into your link, form, or API call.

To go the other direction — turning a messy encoded string back into readable text — paste it into the same tool and click Decode. This is essential when debugging logs or reading tracking URLs.

Encoding Rules to Remember

  • Spaces become %20 (or + in form data — the two conventions are not always interchangeable).
  • Reserved characters (: / ? # & = + @) are only encoded when they appear as data, not as syntax.
  • Non-ASCII characters are UTF-8 encoded first, then percent-encoded byte by byte.
  • Unsafe characters like spaces, quotes, angle brackets, and backslashes should always be encoded.
  • Encoding is reversible: decode returns the original text exactly, provided the encoding was standard.

URL Encoding vs HTML Encoding: Don’t Confuse Them

URL encoding (percent-encoding) makes text safe for URLs. HTML encoding turns characters into entities like & so they display correctly in web pages. They are different systems for different contexts. A common bug: encoding a value for a URL using HTML entities, or vice versa, which produces double-encoded or broken output. When in doubt, encode once for the destination format and no more — double-encoding is a frequent source of mysterious link failures.

The Bottom Line

URL encoding is invisible when it works and infuriating when it doesn’t. Broken links, failed form submissions, and malformed API calls are almost always traced back to unencoded or double-encoded characters. Keep the rules in mind, and when a link misbehaves, run the URL through a URL encoder/decoder to see exactly what the server is receiving. A few seconds of encoding saves hours of debugging.

Leave a Reply