# URL Encoder and Decoder

> Encode text for a URL or decode %XX codes back to text. Pick query value (%20), form data (+) or whole URL; UTF-8 bytes per RFC 3986.

Use it online (free, runs in your browser): https://directory.milunir.com/developer-tools/encoders-decoders/url-encoder-and-decoder/

To URL decode, replace each %XX with the byte it names and read the bytes as UTF-8; to encode, do the reverse for every character outside A–Z, a–z, 0–9 and - . _ ~. For example, café menu becomes caf%C3%A9%20menu, because é is the two bytes C3 A9 and a space is 20.

Links break when a query value carries a space, an ampersand or a letter outside ASCII. This page percent-encodes text the way RFC 3986 describes and decodes it back. Encode mode offers three styles: a query value, where a space is %20 and even / ? & = are escaped; form data, where a space becomes + as an HTML form sends it; and a whole URL, which keeps the colon, slashes, ? and & so the link still opens. Decode mode turns %XX codes into readable text and can read + as a space. Each result shows how many percent escapes it holds. One limit: decoding assumes UTF-8, so very old links written in Latin-1 or Shift_JIS bytes are rejected rather than shown as garbled letters.

## How to use

1. **Choose Encode or Decode**: Encode turns plain text into %XX codes; Decode turns codes back into text.
2. **Paste or open your text**: Type into the box or open a .txt file; it is read in your browser and the result updates as you type.
3. **Pick the encoding style**: Query value for one parameter, Form data for + spaces, Whole URL to keep a full link working.
4. **Set the plus rule when decoding**: Leave 'Read + as a space' on for query strings; turn it off when a + means a real plus sign.

## Examples

### An accented capital A

- Mode: Encode
- Text to encode: À
- Encode as: Query value

Result: Result: %C3%80 Percent escapes: 2 Result length: 6

À is two bytes in UTF-8, C3 and 80, so it becomes two percent escapes.

### A query string from a link

- Mode: Decode
- Encoded text or URL: caf%C3%A9+menu%3F
- Read + as a space: Yes

Result: Result: café menu? Percent escapes: 3 Result length: 10

The + is read as a space, %C3%A9 is the two UTF-8 bytes of é and %3F is a question mark.

### A search phrase as form data

- Mode: Encode
- Text to encode: red shoes size 9
- Encode as: Form data

Result: Result: red+shoes+size+9 Percent escapes: 0 Result length: 16

HTML forms send each space as a plus sign, which is how most search boxes put words in the address bar.

## How it works

`encoded character = % + two hex digits for each UTF-8 byte (RFC 3986 §2.1); unreserved A–Z a–z 0–9 - . _ ~ stay as they are`

Each character is first turned into its UTF-8 bytes: one byte for ASCII, two for é or À, three for most Chinese characters, four for an emoji. In Query value style every byte that is not an unreserved character is written as % plus two upper-case hex digits, so a space is %20 and & is %26; the characters ! ' ( ) * are escaped as well, which JavaScript's encodeURIComponent leaves alone. Form data applies the same rule and then writes %20 as +, following the WHATWG application/x-www-form-urlencoded serializer. Whole URL leaves the reserved delimiters : / ? # [ ] @ ! $ & ' ( ) * + , ; = untouched. Decoding reverses it: each %XX becomes a byte and the byte sequence must be valid UTF-8, otherwise the tool reports which part is broken.

Sources:

- [RFC 3986: Uniform Resource Identifier (URI): Generic Syntax](https://www.rfc-editor.org/info/rfc3986/), IETF / RFC Editor
- [URL Standard](https://url.spec.whatwg.org/), WHATWG

## When not to use it

- Do not use it to hide data; percent-encoding is readable by anyone and is not encryption.
- For binary files or images in a URL, use Base64 or a data URL instead.
- Links in a legacy code page such as Windows-1252 will not decode, since UTF-8 is assumed.

## Common mistakes

- Encoding a whole link in Query value style turns https:// into https%3A%2F%2F and breaks it.
- Encoding twice gives %2520 instead of %20; decode once more to recover the text.
- Reading + as a space in a path, where + is a literal plus sign.
- Leaving a bare % in a value; it must be written as %25.

## Questions

### How do I URL decode a string?

Switch to Decode and paste the string. Every %XX pair is read as one byte, and the bytes are read as UTF-8, so %C3%A9 becomes é and %20 becomes a space. If the result still contains %25 or other codes, the string was encoded twice; paste the result back in and decode again.

### How do I URL encode a space?

Inside a path or a query value, a space is %20, the hex code of byte 0x20. In form data sent by an HTML form, and in many search URLs, a space is written as + instead. Pick Query value for %20 or Form data for +; both decode back to the same space.

### How do I URL encode and decode in JavaScript?

Use encodeURIComponent(value) for one query value and decodeURIComponent(text) to reverse it; encodeURI keeps the slashes and ? of a full link. Note that encodeURIComponent leaves ! ' ( ) * alone, while this page escapes them as RFC 3986 suggests. URLSearchParams writes spaces as +, like the Form data style here.

### How do I URL encode and decode in Python?

Import urllib.parse. quote(text, safe='') gives the Query value result, quote_plus(text) gives the Form data result with + for spaces, and unquote or unquote_plus reverse them. By default quote keeps / unescaped, so pass safe='' when encoding a single parameter.

### How do I URL encode in Java?

java.net.URLEncoder.encode(text, StandardCharsets.UTF_8) follows the form rule, so spaces become + and * stays as it is. For %20 spaces, replace + with %20 in the output, or build the link with java.net.URI. URLDecoder.decode(text, StandardCharsets.UTF_8) reverses it and treats + as a space.

### What does %3D mean in a URL decode?

%3D is the byte 0x3D, the equals sign. It shows up when a value itself contains = so that it is not mistaken for the separator between a parameter name and its value; Base64 tokens ending in == often appear as %3D%3D.

## Use from code or an AI agent

Free JSON API, no key needed. The answer is in `result.stats.primary`.

```bash
curl -X POST https://api.tools-directory.workers.dev/v1/tools/url-encoder-and-decoder \
  -H 'Content-Type: application/json' \
  -d '{"inputs":{"mode":"encode","plain":"À","style":"component"}}'
```

- Inputs (JSON Schema): https://directory.milunir.com/api/v1/tools/url-encoder-and-decoder.json
- MCP server: https://api.tools-directory.workers.dev/mcp (tool `url_encoder_and_decoder`)
- Docs: https://directory.milunir.com/docs/
