URL Encoder

Encode text for safe use in URLs. Converts special characters to percent-encoded format.

0 characters

What is URL Encoding?

URL encoding, also known as percent encoding, is a mechanism for encoding special characters in URLs. URLs can only contain certain characters from the ASCII set, so other characters must be converted to a valid format.

Why Do You Need URL Encoding?

  • Special Characters: Characters like spaces, &, ?, =, and # have special meaning in URLs and must be encoded.
  • International Characters: Non-ASCII characters like accented letters, Chinese, Arabic, or emoji must be encoded.
  • Query Parameters: Values in query strings need encoding to prevent breaking the URL structure.
  • API Calls: Many APIs require URL encoded parameters for proper functionality.
  • Form Submissions: Web forms use URL encoding for GET requests.

Common URL Encoding Examples

  • Space ( ) becomes %20 or +
  • Exclamation mark (!) becomes %21
  • At sign (@) becomes %40
  • Ampersand (&) becomes %26
  • Question mark (?) becomes %3F
  • Forward slash (/) becomes %2F

How Does URL Encoding Work?

URL encoding replaces unsafe ASCII characters with a "%" followed by two hexadecimal digits representing the character's byte value. For example, a space character becomes %20, where 20 is the hexadecimal value for the space character.

When to Use URL Encoding

Use URL encoding whenever you need to include user input or special characters in a URL, especially in query strings, path segments, or API endpoints. This ensures your URLs are valid and function correctly across all browsers and servers. If you need to decode URL encoded strings, use our URL Decoder tool.

URL Encoding in Programming Languages

Every programming language provides URL encoding functions. Here are examples:

PHP

$encoded = urlencode($data); // or rawurlencode($data)

JavaScript

const encoded = encodeURIComponent(data); // Browser & Node.js

Python

from urllib.parse import quote
encoded = quote(data)

Go

import "net/url"
encoded := url.QueryEscape(data)

Java

import java.net.URLEncoder;
String encoded = URLEncoder.encode(data, "UTF-8");

Ruby

require 'uri'
encoded = URI.encode_www_form_component(data)

C#

string encoded = System.Web.HttpUtility.UrlEncode(data);