URL Encoder/Decoder

Data Stays on Your Device

Encode or decode URLs for safe transmission.

Input Text
Loading...
Encoded URL
Loading...

What is the URL Encoder and Decoder?

This tool percent-encodes text for safe inclusion in a URL and decodes percent-encoded strings back to readable text. Percent-encoding replaces characters that have reserved meaning, or that are not permitted in URLs at all, with a percent sign followed by their hexadecimal byte value.

URLs may only contain a restricted set of ASCII characters, and several of those carry structural meaning: ? separates the query string, & separates parameters, = separates a key from its value, and # begins a fragment. If a value you are embedding contains one of these, it must be encoded or it will be misread as structure.

Anything outside the permitted ASCII range is encoded as its UTF-8 bytes, each byte written as a percent sign and two hex digits. A single non-Latin character therefore commonly expands to three or more percent-escapes.

There is an important distinction between encoding a whole URL and encoding one component of it. Encoding an entire URL would destroy its structure by escaping the slashes and colons. Encoding a single query-parameter value is almost always what you actually want.

How to use the URL Encoder and Decoder

  1. Paste your text or URL. Enter the value you want to encode, or the percent-encoded string you want to decode.
  2. Click Encode. Reserved and non-ASCII characters are replaced with percent-escapes.
  3. Click Decode to reverse it. Percent-escapes are converted back to the characters they represent.
  4. Copy the result. Use the encoded value when constructing a URL, or the decoded value when reading one from a log.

Worked examples

Encoding a query parameter value

A search term containing spaces and an ampersand must be encoded, or the ampersand would be read as the start of a new parameter.

Input
coffee & tea
Output
coffee%20%26%20tea

In a full URL: /search?q=coffee%20%26%20tea

Encoding non-ASCII text

Each character is encoded as its UTF-8 bytes, so a single accented or non-Latin character becomes several escapes.

Input
café
Output
caf%C3%A9

What not to do

Encoding an entire URL escapes its structural characters and produces something no client can resolve.

Input
https://example.com/a b
Output
Wrong: https%3A%2F%2Fexample.com%2Fa%20b
Right: https://example.com/a%20b

Encode individual components, not the whole URL.

Common use cases

  • Building query strings. Any user-supplied value going into a query parameter needs encoding to avoid breaking the URL structure.
  • Constructing redirect and callback URLs. OAuth flows pass one URL as a parameter of another, which requires the inner URL to be fully encoded.
  • Reading server logs. Logged request paths are stored encoded, so decoding is needed to see what was actually requested.
  • Handling filenames in URLs. Spaces and punctuation in filenames must be encoded to produce a working link.

Features and limitations

  • Encodes and decodes percent-escapes in both directions.
  • Correctly handles Unicode by encoding characters as UTF-8 bytes.
  • Reports malformed sequences, a stray percent sign not followed by two hex digits, rather than producing broken output.
  • Encodes the input as a URL component, which is the appropriate behaviour for parameter values.
  • Note that a plus sign means a literal plus in a path but a space in application/x-www-form-urlencoded form data. Context determines the correct interpretation.

Frequently asked questions

What is the difference between encodeURI and encodeURIComponent?

encodeURI preserves characters with structural meaning such as slash, colon, question mark, and ampersand, so it is for encoding a complete URL. encodeURIComponent escapes those too, so it is for encoding a single component such as a parameter value. The component form is what you usually want.

Why does one character become several percent-escapes?

Non-ASCII characters are encoded as their UTF-8 byte sequence, and each byte becomes its own escape. The character é is two bytes, so it encodes to %C3%A9.

Is a space %20 or a plus sign?

Both appear in practice. %20 is correct in URL paths and query strings generally, while a plus is used for spaces specifically in form-encoded bodies. Decoding a plus as a space is only correct in that form-encoded context.

Which characters need encoding?

Reserved characters when used literally rather than structurally, question mark, ampersand, equals, hash, slash, plus, percent, along with spaces and everything outside unreserved ASCII, which is letters, digits, hyphen, underscore, period, and tilde.

Is my data sent to a server?

No. Encoding and decoding run in your browser, so URLs containing tokens or internal hostnames stay on your machine.

Why did my URL break after encoding it?

You most likely encoded the whole URL rather than just a component, which escapes the colons and slashes that give it structure. Encode only the values you are inserting.

All processing happens locally in your browser, your data never leaves your device.