TFT

URL Encoder: Encode Special Characters for Web URLs

Use our free URL Encoder to safely convert text for use in web addresses. It ensures your URLs are correctly formatted and work across all browsers and servers. Paste your text and get the encoded result instantly.

URL Encoder

Encode special characters in a URL for internet transmission

Encoding Modes

Full Encode (encodeURIComponent)
Encodes all special characters. Best for encoding query parameter values.
"a b" → "a%20b"
Component Encode
Encodes most characters but preserves some safe ones like / and ?.
"/path?a=1" → "/path?a=1"
encodeURI
Encodes a full URI but preserves reserved characters like : / ? #.
"https://a b.com" → "https://a%20b.com"

How It Works

This URL encoder converts special characters in URLs to their percent-encoded equivalents, making them safe for transmission over the internet.

The encoding process:

  1. Character analysis: Each character is checked against the set of "safe" URL characters (alphanumerics and a few symbols).
  2. Percent encoding: Unsafe characters are converted to % followed by their two-digit hexadecimal ASCII code.
  3. Mode selection: Different encoding modes handle different use cases - full encoding for query values, URI encoding for full URLs.
  4. Output generation: The encoded string is safe to use in URLs, forms, and HTTP requests.

For example, "Hello World!" becomes "Hello%20World%21" - spaces become %20, exclamation marks become %21, ensuring the URL works correctly everywhere.

When You'd Actually Use This

Query Parameter Values

Encode user input before adding it to URL query strings to prevent breaking the URL structure.

API Request Construction

Properly encode parameters when building API URLs programmatically.

Dynamic Link Generation

Create shareable links that include user-generated content or special characters.

Form Action URLs

Encode URL parameters in form actions to ensure proper submission.

Bookmark and Redirect URLs

Prepare URLs containing special characters for bookmarks or redirect chains.

Data in URL Fragments

Encode data passed in URL hash fragments for single-page applications.

What to Know Before Using

Don't encode the entire URL

Only encode specific parts like query values. Encoding the protocol, slashes, or path separators will break the URL.

Different contexts need different encoding

Query parameters need encodeURIComponent, while full URLs need encodeURI. Using the wrong one can over- or under-encode.

Already-encoded text gets double-encoded

Encoding "%20" produces "%2520". Make sure input isn't already encoded before applying encoding again.

Some characters should never be encoded

Characters like : / ? # [ ] @ are URL delimiters. Encoding them changes their meaning and breaks URL parsing.

UTF-8 characters expand to multiple bytes

Non-ASCII characters (emoji, accented letters) encode to multiple %XX sequences. "é" becomes "%C3%A9".

Common Questions

What's the difference between encodeURI and encodeURIComponent?

encodeURI preserves URL structure characters (: / ? #). encodeURIComponent encodes everything except alphanumerics and - _ . ! ~ * ' (). Use encodeURIComponent for query values.

Why do spaces become %20 and not +?

In query strings, + traditionally represents spaces (application/x-www-form-urlencoded). But %20 is the proper percent-encoding. Both work in query values, but %20 is more universal.

Do I need to encode ampersands in URLs?

In query values, yes - & separates parameters so it must be encoded as %26. In the base URL structure, & should be written as & in HTML but & in actual HTTP requests.

What characters are safe in URLs without encoding?

A-Z, a-z, 0-9, hyphen (-), underscore (_), period (.), and tilde (~) are always safe. Everything else should be encoded for maximum compatibility.

Can I manually decode percent-encoded URLs?

Yes, use a URL decoder tool. Each %XX sequence represents one byte - %20 is space (ASCII 32), %21 is ! (ASCII 33), etc.

Why does my encoded URL look so long?

Each special character becomes three characters (%XX). Non-ASCII characters become even longer. This is normal and necessary for URL safety.

Should I encode URLs in email?

Yes, especially if the URL might be line-wrapped. Long encoded URLs are less likely to break at awkward points that invalidate the link.