XML URL Encoder — Free Online Tool

XML URL Encoder

Paste XML and get a URL-encoded string you can put in a query parameter, a form field or a redirect URL without breaking it. Encoding runs in your browser; nothing is uploaded.

How the encoding works

The tool applies JavaScript's encodeURIComponent() to the whole document:

  • Letters, digits and - _ . ! ~ * ' ( ) are left as they are.
  • Everything else becomes %XX escapes of its UTF-8 bytes: < is %3C, > is %3E, " is %22, = is %3D, & is %26, # is %23, a space is %20 and a line break is %0A.
  • Non-ASCII characters (é, ü, 中, emoji) become several escapes, one per UTF-8 byte.
  • Whitespace and line breaks are kept, encoded, so decoding gives back exactly the original text.

Because &, =, ?, / and # are all escaped, the result is safe to drop into a single query-string value: ?data=<encoded>.

Example

<user id="7">
  <name>Ada &amp; Co</name>
</user>

becomes

%3Cuser%20id%3D%227%22%3E%0A%20%20%3Cname%3EAda%20%26amp%3B%20Co%3C%2Fname%3E%0A%3C%2Fuser%3E

Note that &amp; — already an XML entity — is encoded again as %26amp%3B. That is correct: decoding the URL gives back the XML exactly, and the XML parser then turns &amp; into &.

When you need it

  • Passing XML in a GET request — some legacy APIs and payment or SSO gateways take an XML document as a query parameter.
  • Building redirect URLs that carry an XML payload to another system.
  • Debugging — compare what your code produces with a known-good encoding.

Things to know

  • The XML is not validated. Any text is encoded as-is; check it first with the XML Validator.
  • Minify first for shorter URLs. Indentation turns into %20 and %0A sequences. Run the XML through the XML Minifier before encoding.
  • URL length limits. Browsers and servers commonly cap URLs at around 2,000–8,000 characters. For large documents, send XML in a POST body instead.
  • SAML is different. A SAML HTTP-Redirect binding deflates and Base64-encodes the XML before URL-encoding it; this tool performs only the last step.