How to Encode a URL

Quick guide · 2 min read

Quick Answer

URL encoding converts special characters into %XX format so they can be safely transmitted. Use a URL encoder to encode URLs and query parameters instantly.

URL Encoder/Decoder

Encode URLs and parameters instantly

Open Tool →

Common Use Cases

  • Query parameters - Special characters in URLs need encoding
  • API calls - URLs with spaces or special characters must be encoded
  • Form submissions - Browser automatically encodes form data
  • Redirect URLs - URLs passed as parameters need double encoding

Step-by-Step Guide

  1. Enter your URL or text - Paste the URL or parameter value in the URL Encoder
  2. Click Encode - The tool converts special characters to %XX format
  3. Copy the encoded URL - Use the encoded URL in your application or API call

Example

Input:

https://example.com/search?q=hello world&lang=en

Output:

https://example.com/search?q=hello%20world&lang=en

Frequently Asked Questions

What characters need to be URL encoded?
Characters like spaces, quotes, <,>, #, %, {, }, |, \, ^, ~, [, ], `, and non-ASCII characters need encoding. Safe characters include A-Z, a-z, 0-9, hyphen, underscore, period, and tilde.
What is percent encoding?
Percent encoding (URL encoding) replaces unsafe characters with a % followed by two hexadecimal digits. For example, a space becomes %20, and a double quote becomes %22.
What's the difference between encodeURI and encodeURIComponent?
encodeURI encodes a full URL but keeps protocol (://) and domain separators. encodeURIComponent encodes everything, including / and ?, making it suitable for query parameter values.
Do I need to encode URLs in browser address bar?
Modern browsers automatically encode URLs when you type them. However, when building URLs programmatically or sending API requests, you must encode them yourself.