Encode  Decode

### Text/URL Input Sample Live Preview

_https://example.com/path with spaces?param=value_

Encode  Clear

### Encoded URL OutputLive

Start typing to see live preview...

# URL Decoder & Encoder: Decode Percent-Encoded Text

Decode percent-encoded text or encode a query value or path segment. Check special characters and Unicode locally in your browser, free and without an account.

## What Is URL Encoding? Complete Guide to Percent-Encoding

**URL encoding** (also called **percent-encoding**) is a mechanism for encoding characters in a URI (Uniform Resource Identifier) or URL by replacing unsafe characters with a percent sign (`%`) followed by two hexadecimal digits representing the character's UTF-8 byte value. It is defined in [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986).

URLs can only be sent over the internet using the ASCII character set, and certain characters have special meanings within a URL structure (`/` separates path segments, `?` starts the query string, `&` separates parameters, `=` separates key-value pairs, `#` starts a fragment). When these characters appear as data values rather than structural delimiters, or when non-ASCII characters (Unicode) appear in a URL, they must be percent-encoded to avoid ambiguity and ensure correct interpretation by browsers and servers.

For example, a space becomes `%20`, the `@` symbol becomes `%40`, and the character 中 becomes `%E4%B8%AD` in UTF-8. This tool works on the input as a component: if you encode a complete URL, its structural separators are encoded too.

### How to Use the URL Encoder and Decoder

1. **Choose Encode or Decode.** Select Encode for plain text or a URL component, or Decode for percent-encoded text.
2. **Enter the value.** Paste a query parameter value, path segment, or encoded text into the input panel.
3. **Review the result.** With Live Preview enabled, the result appears as you type. Otherwise, select Encode or Decode to process the input.
4. **Copy the output.** Select Copy in the output panel, then use the result in the appropriate URL component or text field.

The page saves your last input in local browser storage and can restore it for 30 days; stored data may remain until cleared. Use Clear when finished and avoid pasting secrets, especially on shared devices.

### URL Encoding vs encodeURI vs encodeURIComponent

JavaScript provides three URL-encoding functions, and choosing the right one matters:

| Function | Does NOT encode | Use case |
| --- | --- | --- |
| `encodeURI()` | A-Z a-z 0-9 ; , / ? : @ & = + $ - _ . ! ~ * ' ( ) # | Encoding a complete URL where you want to preserve structural characters |
| `encodeURIComponent()` | A-Z a-z 0-9 - _ . ! ~ * ' ( ) | Encoding a query parameter value or path segment |
| `escape()` (deprecated) | @ * / + | Legacy - do not use in new code |

This tool is intended for individual parameter values, path components, and data embedded within a URL. It encodes `:`, `/`, `?`, `&`, and `=`, so assemble the address after encoding the values rather than encoding the whole address at once.

### URL Encoding Examples: Common Characters

#### Encoding Example

**Input URL:**

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

**Encoded:**

```
https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Dhello%20world%26lang%3Den
```

#### Common Character Encodings

| Character | Encoded | Name |
| --- | --- | --- |
| space | `%20` | Space |
| `!` | `!` | Exclamation (unchanged here) |
| `#` | `%23` | Hash |
| `&` | `%26` | Ampersand |
| `=` | `%3D` | Equals |
| `?` | `%3F` | Question mark |
| `@` | `%40` | At sign |
| `+` | `%2B` | Plus |

### When to Use URL Encoding: Real Developer Use Cases

#### Query String Parameters

When building URLs with user-provided values as query parameters, always URL-encode the values. A search query like "C++ programming" must be encoded to `C%2B%2B%20programming` to prevent the `+` and spaces from being misinterpreted as URL syntax. Failing to encode allows users to inject arbitrary URL components (URL injection attacks).

#### REST API Requests

When passing data as URL parameters in REST API calls, all parameter values must be URL-encoded. This is especially important for filter values, search terms, email addresses, file paths, and any user-generated content embedded in API URLs. Use `URLSearchParams` in JavaScript to build query strings automatically.

#### Redirect URLs

When implementing login redirects, OAuth callbacks, or post-action redirects where a URL is passed as a parameter, the return URL must be URL-encoded. For example: `/login?redirect=https%3A%2F%2Fapp.example.com%2Fdashboard`. Without encoding, the nested URL would break the outer URL's structure.

#### Internationalized URLs (IDN)

URLs can contain Unicode characters (international domain names, non-Latin path segments) which must be percent-encoded for use in HTTP requests. For example, Chinese, Arabic, or emoji characters in URLs are encoded as UTF-8 byte sequences: the path `/café` becomes `/caf%C3%A9`. Browsers display the decoded "pretty" form while sending the encoded form in HTTP headers.

#### Form Data Submission

HTML form submission with `method="GET"` URL-encodes all form field values and appends them as query parameters. The `application/x-www-form-urlencoded` content type (also used for POST form data) requires all values to be URL-encoded with `+` representing spaces instead of `%20`.

#### Email Links (mailto:)

The `mailto:` URI scheme uses URL encoding for subject, body, and recipient parameters. For example: `mailto:user@example.com?subject=Hello%20World&body=Check%20this%20out%3A%20https%3A%2F%2Fexample.com`. Special characters in the subject and body must be encoded to prevent parsing errors.

### Decode a Query Value Without Breaking the URL

Suppose a search link contains the value `C%2B%2B%20guide`. Select Decode and paste just that value: the result is `C++ guide`. To construct a new link, encode the value separately, then place the result after the parameter name, for example `/search?q=C%2B%2B%20guide`. That keeps the question mark and equals sign as URL structure.

A literal plus sign deserves special attention. This tool leaves `+` unchanged, while form-style query parsing may interpret it as a space. If the source is form-encoded, identify how it was produced before deciding how to interpret the value. An encoded plus, `%2B`, decodes to an actual plus sign.

If a value still contains percent escapes after decoding, it may have been encoded more than once. For example, `%2520` becomes `%20` after one pass and a space after another. Do not decode repeatedly by default: an extra pass can change the meaning of a value or turn encoded separators into structural characters.

For a full address, the [URL Parser](https://www.toolcomb.com/url-parser) can help you inspect the host, path, and query components before working on a value. If the payload is Base64 rather than percent-encoded text, use the [Base64 Encoder and Decoder](https://www.toolcomb.com/base64-encoder). If you are inspecting a JSON response after decoding, the [JSON Formatter](https://www.toolcomb.com/json-formatter) can make it easier to read.

### Code Examples: URL Encoding in Different Languages

#### JavaScript

```
// Encode a parameter value
const encoded = encodeURIComponent("Hello World & more!");
// "Hello%20World%20%26%20more!"

// Decode
const decoded = decodeURIComponent("Hello%20World");
// "Hello World"

// Build a full query string safely
const params = new URLSearchParams({
q: "C++ programming",
lang: "en"
});
const url = `/search?${params}`;
```

#### Python

```
from urllib.parse import quote, unquote, urlencode

# Encode
encoded = quote("Hello World & more!")
# "Hello%20World%20%26%20more%21"

# Decode
decoded = unquote("Hello%20World")
# "Hello World"

# Build query string
params = {"q": "C++ programming", "lang": "en"}
query = urlencode(params)
# q=C%2B%2B+programming&lang=en
```

#### PHP

```
// Encode
$encoded = urlencode("Hello World & more!");
// "Hello+World+%26+more%21"

// rawurlencode follows RFC 3986
$encoded = rawurlencode("Hello World");
// "Hello%20World"

// Decode
$decoded = urldecode("Hello+World");
// "Hello World"
```

#### Node.js

```
const { URLSearchParams } = require("url");

// Encode value
const encoded = encodeURIComponent("Hello World");

// Build query string
const params = new URLSearchParams({
search: "hello world",
filter: "type:image"
});
console.log(params.toString());
// search=hello+world&filter=type%3Aimage
```

### Frequently Asked Questions About URL Encoding

### What is the difference between %20 and + for spaces?

%20 is a percent-encoded space. In form-style query strings, + can also represent a space. This tool decodes %20 as a space but leaves a literal + unchanged; %2B decodes to a plus sign.

### What characters do not need to be URL-encoded?

Letters, digits, hyphen, underscore, period, and tilde are unreserved under RFC 3986. This tool also leaves !, apostrophe, parentheses, and * unchanged; whether additional escaping is needed depends on the destination.

### Is URL encoding the same as HTML encoding?

No. URL encoding represents characters in URL components using percent escapes. HTML entity encoding represents characters for an HTML context. They solve different problems and are not interchangeable.

### Why do I get an Invalid URL encoding error?

An incomplete escape such as %2, non-hexadecimal characters after %, or percent-encoded bytes that are not valid UTF-8 can cause an error. Double-encoded text such as %2520 is valid: one decoding pass produces %20.

### Should I encode the entire URL or just the parameters?

Usually, encode each query value or path segment separately and then assemble the URL. Encoding an entire URL in this tool also encodes separators such as :, /, ?, &, and =, so the output is not an ordinary navigable address.

### Does URL encoding protect against SQL injection or XSS?

No. URL encoding helps represent data in a URL; it does not make input safe for SQL or HTML. Use parameterized queries for SQL and context-appropriate output encoding and other defenses for XSS.

## Related Tools

Discover more free tools that might help with your next task.

[Base64 Encoder Encode and decode Base64 data Use Tool](https://www.toolcomb.com/base64-encoder)

[HTML Encoder Encode and decode HTML entities Use Tool](https://www.toolcomb.com/html-encoder)

[Hash Generator Generate MD5, SHA1, SHA256 hashes Use Tool](https://www.toolcomb.com/hash-generator)

[UUID Generator Generate v1, v3, v4, and v5 UUIDs Use Tool](https://www.toolcomb.com/uuid-generator)

[Password Generator Generate secure random passwords Use Tool](https://www.toolcomb.com/password-generator)

[JWT Decoder Inspect JWT headers and payloads without verifying signatures Use Tool](https://www.toolcomb.com/jwt-decoder)

### Related guides

Read the how-to, then come back to this tool when you are ready to run it locally.

- [How to Decode URL-Encoded Query Strings Percent-encoding and query params, decoded locally while debugging.](https://www.toolcomb.com/blog/how-to-decode-url-encoded-query-strings)
- [How to Encode HTML Entities and Avoid XSS Pitfalls Entity encoding for safe HTML display.](https://www.toolcomb.com/blog/how-to-encode-html-entities-avoid-xss)

[View All Tools](https://www.toolcomb.com/tools)
