About the XML URL Encoder
Angle brackets, ampersands, quotes and newlines all mean something to a URL parser, so an XML document pasted into a query string arrives at the server in pieces. Percent encoding replaces those characters with escape sequences that survive every hop, and this page applies the right variant for where the value is going.
Query value encoding is the safe default: it escapes everything except the unreserved characters, and additionally escapes the exclamation mark, apostrophe, brackets and asterisk that older servers sometimes treat as reserved. Form field encoding does the same but writes spaces as a plus sign, matching the way browsers submit a POST body. Whole URI mode leaves the structural characters such as the slash and question mark alone, which is only correct when you are encoding an address rather than a single value.
Minifying first is on by default and usually cuts the encoded length by a third, because every newline and run of indentation would otherwise become three characters each. The well formedness check is also on, so a truncated paste is caught before you send it somewhere and get a confusing server error back. Type a parameter name to get the finished name=value pair rather than the bare encoding. To read one of these values later, XML URL Decode reverses it and pretty prints the result.
How to use
- Paste the XML document you need to put into a URL or form field.
- Pick the encoding that matches the destination, starting with query value if you are unsure.
- Keep Minify the XML first on to make the encoded string much shorter.
- Add a parameter name to get a complete key and value pair you can append to a URL.
Common questions
- Which mode do I want for a query string?
- Query value. Whole URI mode leaves slashes and question marks unescaped, which corrupts a value placed after the question mark.
- Why is my encoded string still very long?
- Percent encoding costs three characters per escaped byte. Minifying helps, but for large documents a POST body is a better fit than a URL.
- Does it change the character encoding?
- The text is encoded as UTF-8 before percent escaping, which is what servers expect for query values today.
- Can I skip the validity check?
- Yes. Untick the checkbox and any text is encoded as it stands, which is useful for fragments that are not complete documents.