Skip to content
LocalOnly

URL Encoder

Stable

Percent-encode text for safe use in URLs and query strings.

Everything is processed locally in your browser

About URL Encoder

Percent-encode any text so it can be dropped safely into a URL path, query parameter, or fragment. Reserved and unsafe characters - spaces, ampersands, question marks, and non-ASCII text - are converted to their %XX escapes using UTF-8. Choose component encoding for a single value or full-URI encoding when you want to preserve the URL structure.

Features

  • Component mode (encodeURIComponent) for encoding a single query value
  • Full-URI mode (encodeURI) that keeps :/?#[]@ and other structure intact
  • UTF-8 aware, so accented characters and emoji encode to correct %XX bytes
  • Encodes reserved characters like & = ? # and spaces reliably
  • Live output as you type, with one-click copy
  • Character and byte counts for input and encoded output

How to use URL Encoder

  1. 1

    Enter the text to encode

    Paste the value or full URL you want to make URL-safe - a search term, a redirect target, or a query parameter.

  2. 2

    Choose the encoding scope

    Use component mode for a single parameter value, or full-URI mode when you want to keep the scheme, host, and path separators unescaped.

  3. 3

    Copy the encoded string

    The percent-encoded result appears instantly. Copy it into your URL, query string, or code.

Examples

Encode a query value with accents

Component encoding of text containing UTF-8 characters, spaces, and a reserved &.

Input

café & crème

Output

caf%C3%A9%20%26%20cr%C3%A8me

How percent-encoding works

Why URLs need an escape mechanism at all

A URL is not free-form text. Certain characters are structural: `?` starts the query string, `&` separates parameters, `=` splits a name from a value, `/` divides path segments, and `#` begins the fragment. If a value you want to transmit contains any of those, it will be read as structure rather than data, and the URL will be parsed into the wrong pieces.

Percent-encoding solves this by replacing a character with `%` followed by its two-digit hexadecimal byte value. A space becomes `%20`, an ampersand becomes `%26`, a question mark becomes `%3F`. The URL parser sees only unreserved characters and percent triplets, so the structure stays unambiguous while the original value survives intact.

The distinction that matters is between reserved characters used structurally and the same characters appearing inside a value. A `&` between parameters must stay literal; a `&` inside a company name must be encoded. Which is which depends on intent, not on the character - which is why encoding has to be applied to each component separately rather than to a whole URL at once.

encodeURIComponent and encodeURI do different jobs

JavaScript offers two functions and choosing the wrong one is the most common URL bug there is. `encodeURIComponent` encodes everything that is not unreserved, including `/`, `?`, `&`, `=` and `#`. `encodeURI` deliberately leaves those alone because it assumes you are handing it a complete URL whose structure should survive.

The rule is straightforward once stated: use `encodeURIComponent` for individual values - one query parameter, one path segment - and `encodeURI` only for an entire URL you want to make safe without altering its structure. Nearly every practical case is the first one.

Getting it wrong fails in both directions. Using `encodeURI` on a value means an embedded `&` stays literal and splits your parameter in two, which is the shape of a parameter-injection bug. Using `encodeURIComponent` on a whole URL turns every `/` into `%2F` and produces a single unusable string.

Both functions also leave `!`, `'`, `(`, `)` and `*` unencoded, though RFC 3986 lists them as reserved. Most servers cope, but if a strict parser rejects them you have to encode those five manually.

The plus sign is genuinely ambiguous

In `application/x-www-form-urlencoded` - the format HTML forms submit and the convention most query strings follow - a space is encoded as `+`, not `%20`. In the URL specification proper, `+` is a literal plus character. Both conventions are in active use, and they collide in query strings.

The practical consequence bites email addresses. Gmail's `user+tag@example.com` sub-addressing is widespread, and if that `+` is not encoded as `%2B`, a form-style decoder reads it as a space and delivers `user tag@example.com`. This is a real and frequent bug in signup flows and unsubscribe links.

The safe approach is to always encode a literal plus as `%2B` and always use `%20` for spaces. `%20` is valid in both conventions, so it removes the ambiguity entirely rather than relying on the decoder guessing correctly.

Non-ASCII characters and double encoding

Percent-encoding operates on bytes, so a non-ASCII character must first be converted to bytes via UTF-8 and then each byte encoded separately. `é` is two bytes in UTF-8 and becomes `%C3%A9`. A CJK character is typically three bytes and becomes three triplets. This is why an encoded non-Latin string looks so much longer than the original.

Double encoding is the failure to watch for. Encode a string twice and `%` itself becomes `%25`, so `%20` becomes `%2520`. Decoding once then yields the literal text `%20` rather than a space. The tell is a `%25` in a URL where you did not expect one, and the cause is almost always two layers of code each helpfully encoding the same value.

The fix is to be deliberate about where encoding happens - typically once, at the point where the URL is assembled - rather than defensively encoding at every layer.

Reference

Common percent-encodings

CharacterEncodedWhy it matters
space%20 (or + in form data)Cannot appear literally in a URL
&%26Otherwise separates parameters
=%3DOtherwise splits name from value
?%3FOtherwise starts the query string
#%23Otherwise starts the fragment
/%2FOtherwise separates path segments
+%2BOtherwise read as a space in form data
%%25The escape character itself
é%C3%A9Two UTF-8 bytes, encoded separately

Which tool should you use?

These tasks overlap. Here is how to pick the right one for what you are actually doing.

You are putting a value into a query parameter
Encode the value only, with component-style encoding. Never encode the assembled URL.
You have a complete URL to make safe
Use full-URI encoding, which preserves `/`, `?` and `&` as structure.
You need to embed binary data
Percent-encoding would triple its size. Base64-encode it with the URL-safe variant instead.
You are reading an encoded URL
The URL Decode tool reverses this.

Use cases

  • Building query strings where values contain spaces or symbols
  • Encoding redirect_uri and callback URLs for OAuth flows
  • Safely embedding a full URL as a parameter of another URL
  • Preparing search terms for a GET request
  • Escaping user-supplied text before inserting it into a link

Troubleshooting common errors

A query parameter is truncated at an ampersand

Why: The `&` inside the value was not encoded, so the parser read it as a separator.

Fix: Encode each value with component-style encoding before assembling the URL.

An email address loses its plus sign

Why: A form-style decoder read `+` as a space.

Fix: Encode a literal plus as `%2B`. This is worth handling explicitly in any signup flow.

The URL contains %2520

Why: Double encoding - the value was encoded twice.

Fix: Find the two layers that are both encoding and remove one. Encode exactly once, where the URL is built.

Every slash became %2F and the URL broke

Why: Component-style encoding was applied to a whole URL rather than to a single value.

Fix: Use full-URI encoding for complete URLs, and component encoding only for individual values.

Non-Latin text produces a very long URL

Why: Each UTF-8 byte becomes a three-character triplet, so one CJK character costs nine characters.

Fix: Expected. For long non-Latin values, consider a POST body or an internationalised domain name instead.

Limitations

What this tool deliberately does not do, so you know when to reach for something else.

  • Encoding must be applied per component; a whole URL cannot be encoded correctly in one pass.
  • `!`, `'`, `(`, `)` and `*` are left unencoded by the standard JavaScript functions despite being reserved.
  • The `+`-as-space convention is context-dependent and cannot be resolved by the encoder alone.
  • Non-ASCII characters expand to three characters per byte.
  • Encoding is not idempotent - applying it twice corrupts the value.

Frequently asked questions

Learn more

Command Palette

Search for a tool or command