ToolBoxOnline
Developer

URL Encoder — Why Your Link Broke and How %20, %23, and %26 Fix It

You paste a URL into an email and it breaks at the first space. URL encoding fixes that — and understanding it prevents a surprising number of everyday web annoyances.

URL encoderpercent encodingURL decodeencode URL

You copy a link from your browser, paste it into an email, and the link breaks. The URL had spaces in it, or a # symbol, or an & that got interpreted as an HTML entity. What should have been a working link is now a broken string of text that goes nowhere.

Our free URL encoder converts unsafe characters into percent-encoded equivalents that work everywhere — in emails, in code, in APIs, in database queries. Here is what URL encoding actually does and where it matters in your daily digital life.

What characters break URLs (and why)

A URL can only safely contain a limited set of characters: letters (A-Z, a-z), digits (0-9), and a handful of special characters (hyphen, underscore, period, tilde). Everything else — spaces, symbols, non-ASCII characters, even some punctuation — must be percent-encoded.

The encoding is simple: % followed by the character's hexadecimal ASCII code. A space becomes %20. A # becomes %23. An & becomes %26. A ? becomes %3F. The % tells the browser "the next two characters are a hex code, interpret them as the original character."

Common breakage scenarios:

  • Spaces in filenames: "my report.pdf" in a URL becomes "my%20report.pdf." If you skip encoding, the space terminates the URL at "my" and everything after is lost.
  • & in query parameters: ?name=Tom&Jerry — the & splits the query string, so the server sees name=Tom and Jerry as a separate (invalid) parameter. Encode the &: ?name=Tom%26Jerry.
  • # in URLs: the # character starts a fragment identifier. /page#section means "go to /page, then scroll to #section." If your actual content includes #, encode it as %23.
  • Non-ASCII characters: Chinese characters, emoji, accented letters — these are encoded as UTF-8 byte sequences, each byte prefixed with %. "café" becomes "caf%C3%A9."

URL encoding vs slug generation: different tools, different jobs

URL encoding makes a string safe for use in a URL. Slug generation converts a human-readable title into a clean, SEO-friendly URL path segment. They solve different problems:

  • URL encoding: "Hello World & Friends!" → "Hello%20World%20%26%20Friends%21" — preserves every character, just makes them URL-safe. Use this for query parameters, API calls, and any situation where you need the original string to survive a round-trip through a URL.
  • Slug generation: "Hello World & Friends!" → "hello-world-friends" — strips punctuation, lowercases, replaces spaces with hyphens. Use this for blog post URLs, page paths, and SEO-friendly permalinks.

Our URL encoder handles the first case — encode and decode with one click. Our URL slug generator handles the second — convert titles to clean URL paths. Use the right tool for the right job.

Real situations where URL encoding saves you

API calls with user input: a user types "AC/DC" into a search box. Your frontend sends /api/search?q=AC/DC. The slash in "AC/DC" breaks the URL path. Encode the query: /api/search?q=AC%2FDC. Now it works.

Email links with special characters: you email a link to example.com/file?name=report (final).pdf. The parentheses and space break the link in most email clients. Encode: example.com/file?name=report%20(final).pdf. The link survives.

Database storage of URLs: storing raw URLs in a database is fine — until someone inserts a URL with a % that is not percent-encoding. Double-encoding happens: %20 becomes %2520. Always decode before displaying and encode before storing.

For encoding HTML entities instead of URL characters, our HTML entities converter handles &, <, > and more. And for clean URL slugs, see our URL slug best practices SEO guide.

Tools mentioned in this article

Compartir esta herramienta