All tools

URL encoder / decoder

Encode and decode URI text safely.

URL encoder / decoder
Action
InputTEXT

Press Command or Control plus Enter to run. Tab inserts indentation; press Escape, then Tab, to leave the editor.

Result
Your result will appear here.
Ready1 line · 48 chars

About the URL encoder / decoder

URL encoding, also called percent-encoding, replaces characters that aren't allowed or have special meaning in URLs with a % followed by their hex code. A space becomes %20 and & becomes %26, so the value can safely sit inside a query string or path.

This tool encodes text as a URL component and decodes percent-encoded text back to normal. Unicode characters are encoded as UTF-8.

How to use the URL encoder / decoder

  1. Choose Encode or Decode in the Action menu.
  2. Paste the text or encoded value into the Input editor.
  3. Click the action button or press Ctrl + Enter (Cmd + Enter on Mac).
  4. Click Copy result to copy the output.

Examples

Encode a search query for a URL parameter

Input

price < 100 & color = blue/green

Output

price%20%3C%20100%20%26%20color%20%3D%20blue%2Fgreen

Decode a redirect URL

Input

https%3A%2F%2Fexample.com%2Fcallback%3Fstate%3Dabc

Output

https://example.com/callback?state=abc

Common errors and how to fix them

URIError: URI malformed

The text has a % that isn't followed by two hex digits, like 100%. Encode the text first so % becomes %25, or fix the broken escape.

Spaces become + instead of %20

+ for spaces comes from HTML form encoding (URLSearchParams). Both are valid in a query string; in a path, only %20 is. encodeURIComponent always gives %20.

Text is encoded twice (%2520)

%25 is an encoded %, so the value was encoded once already. Decode it once, or remove the second encoding step in your code.

Good to know

  • Encoding works on a single component, so characters such as /, ?, &, = and : are encoded too. Encode each query value separately rather than a whole URL.
  • Letters, digits and - _ . ! ~ * ' ( ) are left unchanged.
  • Decoding fails if the text contains a % that isn't followed by a valid two-digit hex code.

Frequently asked questions

Why is a space sometimes %20 and sometimes +?

%20 is the standard encoding for a space in URLs. + is used only in HTML form data (application/x-www-form-urlencoded). This tool uses %20.

Should I encode the whole URL?

No. Encoding a whole URL also encodes the :// and / separators and breaks it. Encode only the parts you insert, such as a search term or parameter value.

Why does decoding show an error?

Usually because the text contains a lone % or an incomplete code such as %2. Replace a literal percent sign with %25 before decoding.

What does %3A%2F%2F mean in a URL?

It's :// encoded: %3A is a colon and %2F is a slash. It appears when a whole URL is passed as a query value, such as ?redirect=https%3A%2F%2Fexample.com%2Flogin. Paste it into the decoder above, or call decodeURIComponent, to read the original URL.

How do I URL encode in JavaScript or Python?

In JavaScript, encodeURIComponent(value) encodes one component the same way as this tool, and decodeURIComponent reverses it. In Python, use urllib.parse.quote(value, safe=""), or urllib.parse.urlencode to build a whole query string.