Menu

URL Encoder / Decoder

Safely encode and decode URL components.

Last updated

Mode
Scope
DecodedPaste text to begin
Encoded
Percent-encoded or decoded output appears here — Unicode-aware.

What is a URL encoder?

A URL encoder (also called percent-encoder or URI encoder) replaces characters that are reserved or unsafe in URLs with % followed by two hex digits. Developers reach for it when building query strings, escaping path segments, sharing URLs that contain spaces or non-ASCII characters, and debugging redirects.

URLs are restricted to a small set of ASCII characters. Anything outside that set — spaces, accents, emoji, or reserved symbols like ?, #, &, = when used in data — must be percent-encoded so it survives the trip from the browser to the server.

JavaScript exposes two encoding functions: encodeURI (preserves URL structure: /, ?, #, &) and encodeURIComponent (encodes everything reserved). Use encodeURIComponent for *values* you stuff into query strings, and encodeURI for *whole URLs* you want to keep functional.

What you'll learn while encoding URLs

  • Percent-encoding replaces a single byte with % plus two hex digits — for example, a space becomes %20.
  • Reserved characters (: / ? # & = +) have meaning in URL structure. They must be encoded when used as data, not as separators.
  • Non-ASCII text (accents, emoji, Cyrillic, CJK) is first turned into UTF-8 bytes, then each byte is percent-encoded.

How to encode and decode URLs step by step

  1. Pick a direction

    Choose Encode if you have raw text and want it URL-safe. Choose Decode if you have a %-encoded string and want the original text back.

  2. Choose the encoding mode

    Pick encodeURIComponent (encodes everything reserved) for query string values; pick encodeURI (keeps structure) for whole URLs.

  3. Paste your input

    Paste the raw text or the encoded URL. Multiline input works for batch decoding.

  4. Copy the result

    Copy the encoded or decoded value. The conversion runs locally in your browser, so secrets in URLs stay on your machine.

Common URL encodings quick reference

Characters you'll see encoded most often, with their percent-encoded form. Reserved character semantics come from RFC 3986.

CharacterEncodedWhy
space%20Spaces aren't allowed in URLs
!%21Reserved by some servers
#%23Marks the start of a fragment
$%24Reserved character
&%26Separates query parameters
+%2BMeans space in form-encoded bodies
/%2FPath separator
:%3ASeparates scheme and host
=%3DSeparates key from value in query string
?%3FMarks the start of the query string
@%40Separates userinfo and host
UTF-8 byte%C3%A9Each non-ASCII byte is encoded

URL encoding examples to try

Encode a search query

Raw

hello world & more

Encoded

hello%20world%20%26%20more

Spaces become %20, and the & becomes %26 so it isn't mistaken for a query-parameter separator.

Encode non-ASCII characters

Raw

café

Encoded

caf%C3%A9

é is the UTF-8 byte sequence 0xC3 0xA9, so the encoded form has *two* %XX groups for that single character.

encodeURI vs encodeURIComponent

Raw

https://example.com/path?q=hello world

encodeURI

https://example.com/path?q=hello%20world

encodeURIComponent

https%3A%2F%2Fexample.com%2Fpath%3Fq%3Dhello%20world

encodeURI keeps URL structure intact (slashes, ?, =). encodeURIComponent encodes everything reserved — use it on values you put inside a query string, never on a whole URL.

Common URL encoding mistakes

  • Using encodeURI for query string values — the & and = survive the encoding and break parameter parsing.
  • Encoding a URL twice. %2520 instead of %20 is the classic sign of double-encoding bugs.
  • Forgetting that + means space in application/x-www-form-urlencoded bodies but is a literal + in a URL path or query.

URL Encoding FAQ

What is URL encoding?
URL encoding (also called percent-encoding) is a way to represent characters that have special meaning in URLs, or that aren't safe to transmit, by replacing them with % followed by two hex digits.
What is the difference between encodeURI and encodeURIComponent?
encodeURI preserves URL structure characters (/, ?, #, &, =, +). encodeURIComponent encodes them all, which is what you want for individual *values* placed inside a URL — query parameter values, path segments, fragments. See the MDN references for encodeURI and encodeURIComponent.
Why does a space become %20?
Spaces aren't allowed in URLs, so they're replaced with %20, the percent-encoding of the ASCII space character (0x20 in hex).
When should I URL-encode?
Encode any user-supplied or dynamic value before putting it into a URL — query string values, path segments, redirect targets, OAuth parameters. Never trust raw input to be URL-safe.
Can URL encoding be reversed?
Yes — that's URL decoding. decodeURI, decodeURIComponent, or any URL-decoder reverses the percent-encoding back to the original characters.

Learn more

Other developer tools

Learn to code with Coddy

GET STARTED