DevTools

URL Encoder & Decoder Online

Encode or decode URLs to ensure they are properly formatted for web transmission.

What Is URL Encoding?

URL encoding — also called percent encoding — is a mechanism defined in RFC 3986 for representing arbitrary data within a Uniform Resource Identifier. When a URL contains characters that are either reserved (such as &, =, ?, and #) or unsafe for transmission (such as spaces, non-ASCII characters, and control bytes), those characters must be replaced with a percent sign followed by their two-digit hexadecimal code point. For example, a space becomes %20, an ampersand becomes %26, and a Chinese character like 你 becomes its UTF-8 bytes encoded as %E4%BD%A0.

The distinction between reserved and unreserved characters is central to percent encoding. Unreserved characters — A through Z, a through z, 0 through 9, hyphen, underscore, period, and tilde — are safe to use as-is everywhere in a URL. Everything else must be encoded when it appears as data rather than as a structural delimiter. This rule matters most for query parameter values: a value containing an unescaped & would be misread as the start of a new parameter.

JavaScript provides two built-in functions for this purpose: encodeURIComponent encodes everything except unreserved characters and is the correct choice for individual query parameter keys and values; encodeURI preserves the structural characters (/, :, ?, #, &) and is meant for encoding a full URL that is already well-formed. The url encoder and url decoder on this page apply encodeURIComponent-style percent encoding by default.

How to URL Encode a String

Paste the text you want to encode into the input field and select Encode. Every character outside the unreserved set is immediately replaced with its percent-encoded equivalent. To reverse the process, paste a percent-encoded string and select Decode — the tool reconstructs the original bytes and interprets them as UTF-8 text.

For query parameters, always encode the value alone, not the entire URL. Encoding https://example.com/search?q=hello world as a whole will corrupt the structural slashes and colon; instead encode only hello world to get hello%20world and then assemble the URL. If your string has already been encoded once and you see sequences like %2520 (a double-encoded percent sign), run decode twice to recover the original text.

How to URL Encode or Decode a String Online

  1. 1
    Paste your text. Enter a URL with special characters to encode, or a percent-encoded string to decode.
  2. 2
    Choose mode. Select URL Encode or URL Decode.
  3. 3
    Copy the result. The converted string appears instantly. Click copy to use it.
Code Examples
JavaScript / TypeScript
// encodeURIComponent — encode a single query parameter value
const query = "hello world & more";
console.log(encodeURIComponent(query));
// "hello%20world%20%26%20more"

// encodeURI — encode a complete URL, preserving structural characters
const url = "https://example.com/search?q=hello world";
console.log(encodeURI(url));
// "https://example.com/search?q=hello%20world"

// Decode
console.log(decodeURIComponent("hello%20world%20%26%20more"));
// "hello world & more"
Python
from urllib.parse import quote, unquote, urlencode

# Encode a single value (safe='' encodes everything including /)
value = "hello world & more"
print(quote(value, safe=""))
# "hello%20world%20%26%20more"

# Encode a dict of query parameters
params = {"q": "hello world", "lang": "en"}
print(urlencode(params))
# "q=hello+world&lang=en"

# Decode
print(unquote("hello%20world%20%26%20more"))
# "hello world & more"
Go
package main

import (
    "fmt"
    "net/url"
)

func main() {
    // Encode a query parameter value
    value := "hello world & more"
    encoded := url.QueryEscape(value)
    fmt.Println(encoded) // "hello+world+%26+more"

    // url.PathEscape preserves slashes, suitable for path segments
    path := url.PathEscape("path/to my file")
    fmt.Println(path) // "path%2Fto%20my%20file"

    // Decode
    decoded, _ := url.QueryUnescape(encoded)
    fmt.Println(decoded) // "hello world & more"
}
Bash
# Encode with curl (writes encoded form to stdout)
curl -Gso /dev/null -w "%{url_effective}"   --data-urlencode "q=hello world & more"   "https://example.com" | cut -c2-
# ?q=hello%20world%20%26%20more

# Encode using printf + xxd (portable, no curl required)
printf '%s' "hello world" | xxd -plain | tr -d '
' |   sed 's/\(..\)/%\1/g'
# %68%65%6c%6c%6f%20%77%6f%72%6c%64

# Decode with Python one-liner (available on most systems)
python3 -c "import sys, urllib.parse; print(urllib.parse.unquote(sys.argv[1]))"   "hello%20world%20%26%20more"
# hello world & more
Frequently Asked Questions

What is URL encoding (percent encoding)?

URL encoding replaces unsafe characters in a URL with a percent sign (%) followed by two hexadecimal digits. For example, a space becomes %20 and an ampersand becomes %26.

When should I URL encode a string?

You should URL encode any string that will be used as a query parameter, path segment, or fragment — especially if it contains spaces, special characters (&, =, ?, #), or non-ASCII characters like Chinese or emoji.

What is the difference between encodeURI and encodeURIComponent?

encodeURI encodes a full URL but preserves characters like :, /, ?, and #. encodeURIComponent encodes everything except A-Z, a-z, 0-9, and a few symbols, making it suitable for encoding individual query parameter values.

Can this tool decode double-encoded URLs?

Yes. If your URL has been encoded multiple times (e.g., %2520 instead of %20), you can decode it repeatedly until you get the original text.

Related Developer Tools