MagicTools
Back

URL Encoder/Decoder

Mode:

Input

Output

How to use / Why use this tool / FAQ

How to use

Select Encode to convert text into a URL-safe format — spaces become %20, special characters like &, =, and # are percent-encoded into their hex equivalents. Select Decode to reverse the process and convert an encoded URL back to its original, human-readable form. Paste your text into the input field and the result updates instantly without needing to click any button. Click Copy to immediately use the result. This tool is useful for building query strings, debugging URLs with encoded parameters, and preparing text for embedding in HTML href attributes.

Why use this tool

URL encoding is an essential skill for web developers building links, APIs, and query strings with dynamic values. Special characters like spaces, &, =, #, and non-ASCII characters (including Chinese and emoji) must be percent-encoded to be valid in URLs — otherwise browsers and servers may interpret them incorrectly, causing broken links or failed API requests. Use this tool to quickly encode query parameters before adding them to URLs, decode API error messages that contain encoded URL strings, or verify that your URL encoding is correct. Everything runs locally in your browser, with no data sent to any server.

FAQ

What is URL encoding (percent encoding)?
URL encoding replaces unsafe characters with a % followed by two hex digits. For example, a space becomes %20, & becomes %26, and = becomes %3D. It ensures URLs are valid and unambiguous across all systems.
When do I need to URL-encode a string?
Whenever you include user-provided text in a URL — such as query parameters, path segments, or form values. For example, a search query like 'hello world' must be encoded as 'hello%20world' in a URL.
What is the difference between encodeURI and encodeURIComponent?
encodeURI encodes a complete URL and preserves :, /, ?, #, &, =. encodeURIComponent encodes a single component (like a query value) and also encodes those characters. This tool uses encodeURIComponent-style encoding for maximum safety.
Does it support Chinese and non-ASCII characters?
Yes. Non-ASCII characters are first converted to UTF-8 bytes, then each byte is percent-encoded. For example, '中文' encodes to '%E4%B8%AD%E6%96%87'.
Is my data sent to a server?
No. All encoding and decoding runs locally in your browser using JavaScript's built-in functions. Your data never leaves your device.
What characters are NOT encoded in URL encoding?
Unreserved characters are left as-is: letters (A-Z, a-z), digits (0-9), and the four symbols: -, _, ., and ~. Everything else is percent-encoded. For full URLs (not just query values), characters like :, /, ?, #, @, !, $, &, ', (, ), *, +, ,, ;, = may also be left unencoded depending on context.