Tools
Guides

URL Encode / Decode

Encoding

Percent-encoding for URL components and full URLs (RFC 3986).

100% client-side No backend
Input
Output
On this page

What is URL encoding?#

URLs may only contain a small set of unescaped characters — ASCII letters, digits, and a handful of symbols such as -, _, ., ~. Everything else (a space, an &, a Chinese character, an emoji, even a / when it is meant as data rather than a path separator) has to be written as a percent-encoded escape: % followed by two hex digits, like %20 for a space or %E4%B8%AD for the UTF-8 bytes of . URL encoding is the mechanical translation that makes arbitrary text safe to travel inside a URL.

There are two distinct jobs that get conflated all the time, and this tool exposes both through the Options selector:

  • Component mode (the JavaScript encodeURIComponent path) escapes everything that is not a letter, digit, or one of - _ . ! ~ * ' (. Use this when the text is a single piece of data you are about to drop into a query parameter, a path segment, or a fragment — so that characters with structural meaning (/ ? & = #) are reduced to harmless literal text.
  • Full mode (the encodeURI path) escapes the same unsafe bytes but deliberately leaves the URL’s own structural characters alone (: / ? # [ ] @ ! $ & ' ( ) * + , ; =). Use this when you have a complete URL that already has the right shape and you only want to clean up the literal characters inside it.

Decode reverses either form. When the input contains a malformed escape such as %GG (not valid hex) or a lone %, the tool surfaces the error and points at the offending position rather than guessing.

How to use it#

  1. Pick Encode or Decode from the toggle at the top-left.
  2. In Options, choose Component for a single value you are placing into a URL, or Full for an entire URL that should keep its structure.
  3. Paste into the Input pane on the left.
  4. Read the result from the Output pane on the right and click Copy.
  5. Sample loads a demonstration string; Clear resets the panes.

Key features#

  • Two real scopes, not one. Component versus Full mirrors the encodeURIComponent / encodeURI distinction exactly, so you can escape a single value or tidy a whole URL without switching tools.
  • UTF-8 by default. Non-ASCII characters are encoded as their UTF-8 byte sequence (the standard since RFC 3986), so 中文 becomes %E4%B8%AD%E6%96%87, not a single-escape Latin-1 blob.
  • Errors point at the position. When decoding hits an invalid %-escape, the status line reports where it is, instead of throwing the whole input away.
  • Runs locally. Everything happens in your browser; nothing you paste is uploaded.

Worked example#

Encoding the fragment a/b?c=d & e with Component mode produces:

a%2Fb%3Fc%3Dd%20%26%20e

Notice that / becomes %2F, ? becomes %3F, = becomes %3D, the space becomes %20, and & becomes %26 — every character that could otherwise be read as URL structure has been neutralised. This is the correct form for stuffing the whole string into one query value.

Now switch to Full mode and encode a complete URL:

https://example.com/path?q=hello world&lang=zh CN

The result keeps the protocol, slashes, ?, and & intact and only escapes the literal spaces:

https://example.com/path?q=hello%20world&lang=zh%20CN

That is the difference between the two modes in one glance: Component flattens everything to data, Full preserves the URL skeleton and only cleans the bytes that needed it.

FAQ#

Component or Full — how do I decide?#

If you are building a query string and one of the values came from user input, encode that value with Component. If you already have a fully-formed URL that simply contains a few stray characters (spaces, accents), pass the whole thing through Full. A useful test: does the output still need its ?, &, and / to work as a link? Then use Full. Are those characters actually part of the data? Then use Component.

My decoded string has %GG in it and the tool errors out. Why?#

% must always be followed by two hexadecimal digits. %GG is not valid hex, so the decoder refuses it and reports the position — the same input that would throw a URIError in code. Either fix the source so it sends %25 (the encoded form of a literal %) or correct the malformed escape.

Should I encode before or after building the query string?#

Encode each value before you join it with = and &. If you build ?q=a & b first and then encode the whole thing with Component mode, the = and & get escaped too and the server no longer sees them as separators. Encode the pieces, then assemble.

Does this handle Unicode the same way browsers do?#

Yes. Modern browsers and servers expect percent-escapes to carry UTF-8 bytes, and that is what this tool emits — becomes %E4%B8%AD. If you are debugging an old system that expects a legacy single-byte encoding (Latin-1, GBK, etc.), the bytes will differ and you will need an encoding-specific tool.