About the URL Encoder
This tool converts text or full URLs into percent-encoded format for safe use in web addresses, or reverses a percent-encoded string back into readable text. It is aimed at developers, marketers building tracking links, and anyone who needs to safely pass special characters through a URL.
How It Works
Type or paste text or a URL and choose encode or decode mode. In encode mode, the calculator runs the input through standard URI component encoding, converting spaces, symbols, and non-ASCII characters into percent-escaped sequences. In decode mode, it reverses percent-escaped sequences back into their original characters. If the decode input contains malformed percent-encoding, the calculator returns an error rather than a garbled result.
Formula & Methodology
Encoding works by scanning the input character by character and replacing any character outside the safe URL character set (letters, digits, and a small set of punctuation marks) with a percent sign followed by its two-digit hexadecimal code, for example a space becomes %20. Decoding reverses this by finding each percent sign followed by two hex digits and converting that triplet back into the original character.
Examples
Encoding a search query
Encoding the text 'https://example.com/search?q=hello world' converts the space in 'hello world' to %20 and also encodes the colon, slashes, and question mark, since the entire string is treated as one component.
Decoding a percent-encoded string
Decoding 'hello%20world%21' converts %20 back to a space and %21 back to an exclamation mark, returning the readable text 'hello world!'.
Advantages
- Handles both directions in one interface, so the same tool encodes plain text and decodes percent-encoded strings
- Uses the same standard encoding function browsers and web frameworks rely on, so results match what real applications produce
- Catches malformed decode input with a clear error instead of silently returning broken or partial text
Common Mistakes
- Encoding an entire URL as a single component when only a query parameter value needed encoding, which unintentionally escapes the slashes and colons that should stay intact
- Assuming encoding is a form of security or obfuscation, when it is only a compatibility format for embedding special characters and non-ASCII text in a URL
- Attempting to decode text that was never percent-encoded, which usually just returns the original text unchanged but can error out if it happens to contain a stray percent sign
Edge Cases to Watch For
- Decoding a string with an incomplete or malformed percent sequence, such as a lone percent sign not followed by two valid hex digits, triggers an error rather than a partial or corrupted decode
- Encoding is applied to the entire input as one component, so a full URL with a protocol and slashes will have its slashes and colons encoded too, which is appropriate for a query parameter value but not for encoding a whole URL meant to remain clickable
- Characters already considered URL-safe, such as letters, digits, and a handful of punctuation marks, pass through encoding unchanged
Common Use Cases
- Developers testing how query parameters or special characters should appear in a URL
- Marketers building or troubleshooting campaign links that include spaces, ampersands, or other special characters
- Anyone decoding a long, encoded URL from an email or browser address bar back into readable text