PlayTools

Why a URL encoder exists at all

URL의 특수문자를 퍼센트 인코딩하거나 퍼센트 인코딩된 URL을 읽기 가능한 텍스트로 디코딩합니다.

Runs in your browser — nothing you enter is uploaded
https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Dhello%20world%26lang%3D%E4%B8%AD%E6%96%87

Which URL encoder mode do you need?

This is your one real decision, and that toggle above is all of it. encodeURIComponent is for one piece of a URL — one query value, one path segment, one token. It escapes every structural character, because inside one URL value those characters are text. encodeURI is for a whole URL, already assembled correctly and needing only its unsafe characters cleaned up, so it leaves URL structure alone.

Run https://example.com/search?q=hello world through both modes and your difference is obvious. encodeURI escapes only that space and leaves a working URL. Component mode escapes colon and both slashes as well, returning https%3A%2F%2Fexample.com%2F… — correct only when that entire URL is about to become one parameter inside another URL, such as an OAuth redirect target.

Rule of thumb: build your URL first, then encode each URL value as you put it in. If you find yourself running this URL encoder over text that already contains a ? you meant to keep, you want another mode.

What a URL encoder does to each character

Percent-encoding replaces a character with % and its byte in hex. Both URL encoder modes agree on most of that alphabet, and disagree on exactly those characters which give the URL its structure:

encodeURIComponent turns the structural characters slash, question mark, hash, ampersand, equals, colon, at and plus into %2F, %3F, %23, %26 and so on, while encodeURI leaves them as-is. Both turn a space into %20, a percent sign into %25 and an e-acute into %C3%A9, and both leave letters, digits, hyphen, underscore, full stop and tilde alone.
space → %20
Most parsers end a URL at its first space, and mail clients stop linking there.
& → %26 / &
Unencoded, this starts a new query parameter — commonest way one URL value gets truncated.
= → %3D / =
Splits key from value, so an unencoded = inside the value confuses strict parsers.
? → %3F / ?
Starts a query string. Two raw question marks in one URL are tolerated but never portable.
# → %23 / #
Starts a fragment, and fragments never reach your server. Everything after a raw # is lost.
/ → %2F / /
Separates path segments, so an unencoded / inside the value invents another segment.
+ → %2B / +
Form decoders read this as space, which is why plus signs vanish from email addresses in a URL.
% → %25
Escapes itself. Skip this and an already-encoded URL decodes into nonsense twice over.
é, 中, 🎉 → %C3%A9 …
Encoded as UTF-8 bytes, so one character becomes two, three or four triplets.

Letters, digits and - _ . ~ are unreserved and never change in either mode. JavaScript also leaves ! * ' ( ) alone, which is that language rather than RFC 3986 — strict encoders escape those too, so two URL encoders can both be right and still disagree.

Double encoding, and the plus-sign trap

If you see %2520 in a URL, something encoded it twice. One pass turned space into %20; a second read that % as an ordinary character and turned it into %25, leaving %25 + 20. It happens when your framework already encoded the value and some helper did it again. Decode once here; if your result still holds % sequences, decode again, then fix whichever layer is doubling up.

Plus signs are another classic. In query strings built by an HTML form — application/x-www-form-urlencoded — space is written as +, not %20. Percent-decoding does not know that rule: decode a+b here and you get a+b back, not a b. When reading form data, replace + with space before decoding. Going outward, one real plus inside the value must become %2B or it arrives as space — which is exactly why name+tag@example.com keeps losing its plus in signup forms.

One security note: URL decoding is not sanitising. Decoded URL text can contain anything, so validate it before it reaches your database, your filesystem or another URL. Percent-encoding hides ../ and script tags just as happily as it hides spaces.

Where URL encoding shows up in practice

Tracking links are your everyday case: every UTM parameter, every ?q= pasted out of a search box. OAuth redirect URIs are what people get wrong, because a whole callback URL becomes one parameter inside an authorise URL and must be component-encoded. API tokens need it whenever Base64 puts + or / inside them. Non-ASCII hosts use a different scheme entirely — punycode, so münchen.de becomes xn--mnchen-3ya.de, while the URL path after it percent-encodes normally.

One confusion worth naming: URL encoding is not HTML encoding. Percent-encoding makes text safe inside a URL; HTML entities make text safe inside markup. One ampersand becomes %26 in a URL and & in a page, so if & is turning up in your address bar, something ran the HTML encoder where this one belonged.

In code the same two modes keep the same names. JavaScript gives you encodeURIComponent(value) and encodeURI(url), with decodeURIComponent and decodeURI to reverse them. Python splits the same idea into urllib.parse.quote and quote_plus, and PHP into rawurlencode (space becomes %20) and urlencode (space becomes +) — the plus-sign trap again, baked into a standard library.

A URL encoder is not the same job as making the URL readable. If you want Café Münster to become cafe-munster rather than Caf%C3%A9%20M%C3%BCnster, that is the slug generator. And if a token you are decoding turns out to be Base64 rather than percent-encoded, the Base64 decoder is the one you want.

Why a URL encoder exists at all

The URL was specified in 1994 with a deliberately small alphabet: letters, digits and a handful of punctuation marks, because the URL had to survive being written on paper, read down a phone line and retyped by hand. Everything outside that set gets smuggled through as percent-escapes, which is what percent-encoding is — one character becomes % followed by its byte value in hexadecimal, so %20 is simply byte 32, space.

RFC 3986 splits that alphabet in two, and this split is the whole idea. Unreserved characters — letters, digits and - _ . ~ — mean one thing everywhere and stay untouched. Reserved characters such as / ? # & = : @ are punctuation belonging to the URL itself, each with a job: separating path segments, starting the query, marking the fragment. Percent-encoding one says you want it read as text rather than as URL structure, which is why any URL encoder escapes the same character in one place and not another.

Non-ASCII text came later and works in two steps: each character becomes UTF-8 bytes, then every byte becomes its own triplet. That is why an accented letter costs two triplets, a CJK character three and an emoji four — and why the same URL in any language but English looks so much longer than its readable form. Decode with the wrong charset assumption and you get mojibake rather than an error, which makes it a quiet bug.

None of this is compression or security. A percent-encoded URL holds the same information in longer form, readable by anyone, and any URL decoder reverses it in one pass. Percent-encoding exists so arbitrary text can travel inside a format that reserves a dozen characters for its own grammar — nothing more, and nothing to rely on for hiding a URL value.

Worked examples

encodeURIComponent("café & crème")
  → caf%C3%A9%20%26%20cr%C3%A8me

encodeURI("https://example.com/a b?q=café&x=1")
  → https://example.com/a%20b?q=caf%C3%A9&x=1

Component mode encodes &, =, ? and / so a value cannot break out of its place in the URL; full-URL mode leaves those structural characters alone and only encodes what is not allowed anywhere. When building a query string in code, encode each value with encodeURIComponent, or let URLSearchParams do it for you.

Decoding pitfalls

  • A + in a query string from an HTML form means a space; decodeURIComponent leaves it as +, so replace + with a space first when decoding form data.
  • A stray % that is not followed by two hex digits makes decoding fail — the text was probably never encoded, or was cut off.
  • If a value still contains %XX after decoding, it was encoded twice; decode once more.

In-depth guides

These free tools pair well with this page — open them in a new tab to finish your workflow.

자주 묻는 질문

URL 인코딩이란 무엇인가요?

URL 인코딩(퍼센트 인코딩)은 URL에서 허용되지 않는 문자를 안전한 형식으로 변환합니다. 예를 들어 공백은 %20이 되고 &는 %26이 됩니다.

언제 URL 인코딩이 필요한가요?

공백, &, =, + 또는 비ASCII 문자가 포함된 텍스트를 URL 쿼리 문자열에 포함할 때 인코딩이 필요합니다.

encodeURI와 encodeURIComponent의 차이점은 무엇인가요?

encodeURI는 전체 URL을 인코딩하면서 /, ?, & 같은 문자는 그대로 둡니다. encodeURIComponent는 URL 구성요소(쿼리 값 등)를 인코딩하여 이러한 문자도 변환합니다. 개별 파라미터 값에는 encodeURIComponent를 사용하세요.

전체 URL을 인코딩해야 하나요, 아니면 일부만 인코딩해야 하나요?

전체 URL이 아닌 개별 쿼리 파라미터 값을 인코딩하세요. 전체 URL을 인코딩하면 슬래시와 콜론도 인코딩되어 URL 구조가 깨집니다.

인코딩이 필요 없는 문자는 무엇인가요?

비예약 문자인 알파벳(A–Z, a–z), 숫자(0–9), -._~는 인코딩이 필요 없으며 그대로 전달됩니다.

모든 인코딩된 문자열을 디코딩하는 것이 안전한가요?

디코딩 자체는 일반적으로 안전하지만, 신뢰할 수 없는 입력을 디코딩하여 URL이나 데이터베이스 쿼리에 사용할 때는 인젝션 취약점에 주의하세요.