Encoding · Developer Guide
URL Encoding Explained
Encoding the wrong part of a URL can change its structure. Decide whether you are encoding one value, building a query string, or inspecting a complete URL before selecting a tool.
What is percent encoding?
Percent encoding represents bytes as % followed by two hexadecimal digits. It lets a component contain characters that would otherwise serve as URL separators. The Small Tools encoder uses encodeURIComponent for one component, not a full URL.
How to build a query safely
Encode the value before joining it to a parameter name. For multiple parameters in application code, URLSearchParams handles query construction and form-style space encoding. Inspect the resulting query to confirm repeated keys and empty values have the meaning your server expects.
Example: keep an ampersand inside one value
Without %26, the ampersand could start another query parameter. Encoding the entire final URL would also encode its colon, slashes, and question mark, so it would no longer be usable as that URL.
Original value: Tom & Jerry
Encoded value: Tom%20%26%20Jerry
Final URL: https://example.com/search?q=Tom%20%26%20JerryCommon mistakes
- Double encoding: %20 becomes %2520 when passed through the encoder again. Track which layer owns encoding.
- Treating + the same everywhere: decodeURIComponent keeps + as +; form-style query parsing with URLSearchParams treats it as a space. A literal plus in a query value should be encoded as %2B.
- Decoding malformed percent sequences: incomplete escapes or invalid UTF-8 produce an error.
- Using percent encoding as HTML escaping: URL construction and safe HTML rendering solve different problems.
Practical use cases and limits
When a search term containing spaces, Unicode, or & fails, inspect the outgoing URL and compare the parsed query on the receiving side. For a signed URL, follow the signature protocol exactly; decoding and re-encoding can change bytes or parameter ordering and invalidate the signature.
The tools run locally and do not navigate to the supplied URL. Percent encoding does not hide tokens from browser history, server logs, or recipients of a shared link. Keep credentials out of URLs where possible.
Related tools
- URL Encoder — Encode text for safe use in URL components.
- URL Decoder — Decode percent-encoded URL components.
- Query String Parser — Decode a query string and group repeated parameter values.
- URL Parser — Break an absolute URL into its protocol, host, path, and query fields.