URL encoding (also called percent-encoding) is a mechanism for encoding information in a Uniform Resource Identifier (URI) so that only characters allowed by RFC 3986 appear in the final string. Any character that is not an unreserved character (A–Z, a–z, 0–9, -, _, ., ~) is replaced by a percent sign followed by two hexadecimal digits representing the character's UTF-8 byte value — for example, a space becomes %20 and & becomes %26.
Percent-encoding is required because URLs can only contain a limited set of ASCII characters. When a URL includes characters outside this set — spaces, Unicode letters, symbols like &, =, or / used as literal values rather than structural delimiters — those characters must be encoded to prevent the URL parser from misinterpreting them. This is especially critical for query string values, where unencoded & or = would break the parameter structure.
Why Use This Tool?
Instantly see how your text encodes under both modes, with a live side-by-side comparison — no need to write code to check edge cases.
⚡
Live Preview
Output updates as you type. Try different inputs and instantly see which characters get encoded and which are preserved.
🔀
Two Modes
Switch between encodeURIComponent (for values) and encodeURI (for full URLs) without leaving the page.
🔒
Client-side Only
All encoding runs locally in your browser. Sensitive query parameters and tokens never touch a server.
📋
Copy in One Click
Copy the encoded output to clipboard with a single button. Ready to paste directly into your code, terminal, or browser address bar.
How to Use This URL Encoder Online
No account, no installation. Paste or type your text into the input field and the percent-encoded result appears instantly. Everything runs in your browser — your data never leaves your device.
1
Paste Your Text or URL
Enter any string — a query parameter value, a full URL, a path segment, or a JSON payload. The encoder processes it character by character according to RFC 3986.
2
Choose the Encoding Mode
Select encodeURIComponent to encode individual parameter values (encodes everything except unreserved characters). Select encodeURI to encode a full URL while preserving its structural characters like ://?#&=.
3
Copy the Encoded Output
The percent-encoded string appears instantly. Click Copy to grab the result and paste it directly into your API call, form action, or config file.
4
Decode It Back if Needed
Made a mistake or want to verify the result? Switch to the URL Decoder tool with one click to reverse the encoding.
Which Characters Get Encoded?
RFC 3986 divides URL characters into two categories: unreserved characters (never encoded) and reserved characters (have special meaning — encoded or preserved depending on context). The table below shows how the two JavaScript functions treat key characters:
Char
Meaning in URL
encodeURIComponent
encodeURI
Space
word separator
%20
%20
+
plus sign
%2B
%2B
/
path separator
%2F
/ (kept)
?
query start
%3F
? (kept)
#
fragment
%23
# (kept)
&
param separator
%26
& (kept)
=
param value
%3D
= (kept)
@
auth separator
%40
@ (kept)
:
scheme / port
%3A
: (kept)
%
percent literal
%25
%25
~
unreserved
~ (kept)
~ (kept)
-_.~
unreserved set
kept as-is
kept as-is
encodeURIComponent vs encodeURI
JavaScript provides two encoding functions with very different behavior. Choosing the wrong one is one of the most common URL-handling bugs:
encodeURIComponent()
Encodes everything except the unreserved character set (A–Z a–z 0–9 - _ . ~). This is the right choice for encoding individual query parameter values, path segments, or any value that will be embedded inside a URL. It will encode /, ?, #, & and all other reserved characters.
encodeURI()
Preserves the entire URL structure by leaving reserved characters (: / ? # [ ] @ ! $ & ' ( ) * + , ; =) unencoded. Use this only when you have a complete URL with structure you want to preserve, and only need to encode the non-ASCII or illegal characters within it.
Common Use Cases
Query String Parameters
Encode parameter values before appending them to a URL: name=John%20Doe instead of name=John Doe. Unencoded spaces and special characters will break URL parsers and produce unexpected results.
API Request Building
REST APIs require properly encoded query parameters. Encoding values with encodeURIComponent prevents injection of extra parameters via characters like & and = embedded in values.
Form Data Submission
HTML forms submit data as application/x-www-form-urlencoded by default. Understanding percent-encoding helps debug what the browser sends and what the server receives.
Path Segments with Special Chars
File names or identifiers that contain spaces, slashes, or unicode characters must be percent-encoded when used as URL path segments: /files/my%20document.pdf.
OAuth & Auth Tokens
OAuth 1.0a and some authentication protocols require the base string to be constructed from percent-encoded parameter names and values following a strict normalization algorithm.
Deep Links & Share URLs
When generating shareable URLs that embed user content (search queries, filter state, coordinates), encode all dynamic values to prevent broken links and XSS via URL manipulation.
Code Examples
How to URL-encode strings in popular languages and environments:
JavaScript (browser / Node.js)
// Encode a query parameter value (most common case)
encodeURIComponent('hello world & more') // → "hello%20world%20%26%20more"
// Encode a complete URL (preserves ://?#& structure)
encodeURI('https://example.com/path?q=hello world') // → "https://example.com/path?q=hello%20world"
// Build a query string safely
const params = new URLSearchParams({ q: 'hello world', lang: 'en' })
const url = `https://example.com/search?${params}` // uses + for spaces
Python
from urllib.parse import quote, urlencode, quote_plus
# Encode a path segment or query value
quote('hello world & more') # → 'hello%20world%20%26%20more'
# Encode for application/x-www-form-urlencoded (space → +)
quote_plus('hello world') # → 'hello+world'
# Build a query string
urlencode({'q': 'hello world', 'lang': 'en'}) # → 'q=hello+world&lang=en'
Node.js (URL API)
const url = new URL('https://example.com/search')
url.searchParams.set('q', 'hello world & more')
url.searchParams.set('lang', 'en')
console.log(url.toString())
// → https://example.com/search?q=hello+world+%26+more&lang=en
Several tools can percent-encode text, but they differ in control, privacy, and context.
This Tool
Browser-based, instant, private. Supports both encodeURIComponent and encodeURI modes. No data sent to any server. Handles full Unicode input.
Browser Address Bar
Browsers auto-encode URLs when you paste them, but only partially — they preserve many special characters for readability. Not suitable for encoding parameter values.
URLSearchParams / urllib
The correct programmatic approach for building URLs in JavaScript or Python. Use this tool for quick one-off encoding or to verify what your code will produce.
Frequently Asked Questions
What is the difference between %20 and + for spaces?
Both represent a space, but in different contexts. %20 is the standard percent-encoded representation of a space and is valid everywhere in a URL. The + sign represents a space only in the application/x-www-form-urlencoded format (HTML form submissions). In a URL path or a raw query value, + is a literal plus sign, not a space. Use %20 for maximum compatibility.
When should I use encodeURIComponent vs encodeURI?
Use encodeURIComponent for individual values (query parameters, path segments, hash fragments). Use encodeURI only when you have a complete URL and want to preserve its structure. A common mistake is using encodeURI on a query value — it will leave & and = unencoded, breaking the query string.
Does URL encoding handle Unicode characters?
Yes. Non-ASCII characters are first converted to their UTF-8 byte representation, then each byte is percent-encoded. For example, the euro sign € (U+20AC) encodes to %E2%82%AC — its three UTF-8 bytes. Both encodeURIComponent and encodeURI handle this correctly in all modern browsers.
Is double-encoding a problem?
Yes. If you encode an already-encoded string, %20 becomes %2520 (the % itself is encoded to %25). Always encode raw values, not previously encoded ones. When in doubt, decode first, then re-encode.
What characters are always safe in URLs?
The unreserved characters defined by RFC 3986 are always safe and never need encoding: uppercase A–Z, lowercase a–z, digits 0–9, hyphen (-), underscore (_), period (.), and tilde (~). Everything else should be percent-encoded when used as a value rather than as a structural delimiter.
Why do some URLs contain uppercase hex (%2F) and others lowercase (%2f)?
Both are valid. RFC 3986 specifies that percent-encoded sequences are case-insensitive, so %2F and %2f are equivalent. However, the same RFC recommends using uppercase hex digits for consistency. Most browsers and libraries produce uppercase.
Does this tool encode the full URL or just the parameters?
Both. Use encodeURIComponent mode to encode individual query parameter values (the most common use case). Use encodeURI mode to encode a complete URL while preserving its structural characters like ://, ?, #, and &.
Is there a length limit for encoding?
No server-side limit — the tool runs entirely in your browser. Practical limits depend on your browser's memory. For very large inputs or batch processing, use encodeURIComponent in a script instead.