Free Online Tool

URL Encode / Decode

Encode special characters for URLs or decode percent-encoded strings

Client-side processing — your data never leaves your browser

Text Input

Text or URL to encode

Input

Encoded Output

URL-encoded result

Output

What Is URL Encoding?

URL encoding (also called percent-encoding) converts characters that are not allowed in URLs into a format that can be safely transmitted. Characters are replaced with a % sign followed by their two-digit hexadecimal ASCII value. For example, a space becomes %20, and an ampersand becomes %26.

This encoding is defined in RFC 3986 and is essential for constructing valid URLs, especially when query parameters contain spaces, special characters, or non-ASCII characters like accented letters and emoji.

encodeURIComponent vs encodeURI

JavaScript provides two URL encoding functions with different scopes:

encodeURIComponent

Encodes everything except: A-Z a-z 0-9 - _ . ~ ! * ' ( )

Use this for encoding individual query parameter values or path segments. It encodes =, &,/, and ? — which is correct for parameter values but would break a full URL structure.

encodeURI

Preserves URL structural characters: : / ? # [ ] @ ! $ & ' ( ) * + , ; =

Use this for encoding a complete URL while preserving its structure (protocol, host, path, query delimiters). Only non-ASCII characters, spaces, and a few others get encoded.

Common Characters and Their Encodings

CharacterEncodedDescription
(space)%20Space character
!%21Exclamation mark
#%23Hash / fragment identifier
&%26Ampersand (query separator)
=%3DEquals (key=value separator)
?%3FQuestion mark (query start)
/%2FForward slash (path separator)
@%40At sign
+%2BPlus sign

When to Use URL Encoding

API Query Parameters

When constructing API calls with dynamic values, always encode parameter values to prevent special characters (spaces, ampersands, equals signs) from breaking the URL structure.

Form Submissions

HTML forms with method="GET" automatically URL-encode field values. Understanding encoding helps debug form data in browser dev tools and server logs.

Redirect URLs

OAuth flows and SSO systems pass redirect URLs as query parameters. The redirect URL itself must be encoded so its ? and & don't get confused with the outer URL's delimiters.

Log Analysis

Server logs and analytics platforms show URLs with percent-encoded characters. Decoding them reveals the actual search terms, usernames, or file paths users requested.

Related Tools

Built by JDApplications