About URL Encoder / Decoder
URLs are the addresses of the modern web, but they cannot safely contain every character you might type into a form or document. Spaces, ampersands, percent signs, non-ASCII letters, and reserved symbols can break a link, alter query parameters, or cause a server to misinterpret your request. URL encoding—also called percent-encoding—solves this by replacing unsafe characters with a percent sign followed by two hexadecimal digits. This URL Encoder / Decoder makes that transformation transparent and reversible. The tool follows the behavior of JavaScript's encodeURIComponent and decodeURIComponent. It encodes almost all characters except the unreserved set: A–Z, a–z, 0–9, hyphen, underscore, period, tilde, and the exclamation, asterisk, and single-quote symbols. A space becomes %20, an ampersand becomes %26, a question mark becomes %3F, and a hash becomes %23. Unicode characters are first encoded as UTF-8 bytes, so the letter é becomes %C3%A9 and the Chinese character 中 becomes %E4%B8%AD. Decoding reverses the process, turning percent sequences back into the original text. By the end of this session you will know when to encode an entire URL versus only its components, why a space may appear as %20 or + depending on context, and how to diagnose malformed encoded strings. You will also understand that URL encoding is not encryption—anyone can decode it in seconds—so it should never be used to protect sensitive data. It is a routine step in web development, API design, and search engine optimization when building links that contain spaces or query strings. It is therefore one of the most common transformations in modern web workflows.
How It Works
The tool has two modes. In encode mode it passes the input through encodeURIComponent, which examines each character. Unreserved characters—letters, digits, and a small set of punctuation—pass through unchanged; every other character is converted to one or more percent-encoded UTF-8 bytes. In decode mode it passes the input through decodeURIComponent, which scans for percent signs followed by valid hex pairs and reconstructs the original characters. If the input contains an invalid sequence—such as a lone percent sign or a percent not followed by two valid hex digits—the tool catches the error and returns a clear failure message instead of throwing a cryptic error. The conversion is deterministic: encoding the same text twice in a row always produces the same output, and decoding valid output always recovers the original text. The tool also guards against malformed input, so a missing or wrong hex digit does not crash the conversion.
Formula & Calculation Logic
There is no single algebraic formula; URL encoding is a lookup-and-substitution process defined by RFC 3986. Each unsafe byte is represented as a percent sign plus the byte's two-digit hexadecimal value. For example, the ASCII code for '&' is 38, which is 0x26, so it becomes %26. The space character (ASCII 32, 0x20) becomes %20, although HTML forms historically encode spaces as +. Unicode characters are expanded to UTF-8 bytes first, then each byte is percent-encoded. Decoding simply reverses those steps. For example, the slash character (0x2F) becomes %2F, which is why encoding a full URL can break its structure.
Step-by-Step Guide
- Choose Encode to make text URL-safe, or Decode to recover original text.
- Paste the text or encoded string into the input field.
- In encode mode, the tool replaces unsafe and non-ASCII characters with percent-encoded sequences.
- In decode mode, the tool converts percent sequences back into the original characters.
- Review the output and copy it into your URL, query string, API payload, or test script.
Example Calculations
- Scenario 1: You want to pass the search query 'hello world & more' as a URL parameter. Encoding produces 'hello%20world%20%26%20more', which will not be misread as multiple parameters.
- Scenario 2: You receive the encoded path 'r%C3%A9sum%C3%A9'. Decoding reveals the original word 'résumé', confirming the file name uses accented characters.
Common Use Cases
- Building safe query parameters for search forms and API requests.
- Encoding file names and path segments that contain spaces or special characters.
- Decoding URLs captured in server logs or analytics reports.
- Preparing email and chat links that include special symbols.
Pro Tips
- Encode individual components (path segments, query values) rather than the entire URL, or you will encode the scheme and slashes.
- Use + for spaces only in application/x-www-form-urlencoded bodies, not in generic URLs.
- Always decode before analyzing a URL; looking at raw percent sequences can hide typos.
- Remember that URL encoding is reversible, not encrypted—do not use it for passwords or secrets.
Common Mistakes to Avoid
- Encoding a complete URL including 'https://', which turns the slashes into %2F and breaks the link.
- Double-encoding text, which turns a space into %2520 instead of %20.
- Mixing %20 and + for spaces in the same string without knowing the convention.
- Trying to decode a string that was never encoded, which can throw an error.
Why Use This Tool?
- Prevents broken links caused by spaces and reserved characters.
- Makes API parameters predictable and server-safe.
- Saves time when debugging encoded URLs in logs.
- Handles international characters through UTF-8 percent encoding.