URL Encode XML
URL-encode XML content for safe use in URLs, query strings, and API parameters
Paste raw XML into a URL parameter and watch it break — angle brackets, ampersands, and colons all clash with URL syntax. This tool percent-encodes your XML in one click so it’s safe for query strings, API calls, and form data. And everything runs in your browser. Nothing gets uploaded.
How It Works
Under the hood, this uses JavaScript’s encodeURIComponent function. It scans every character and replaces anything that isn’t a letter, digit, or one of a few safe punctuation marks (- _ . ! ~ * ' ( )) with its percent-encoded equivalent. So < becomes %3C, spaces become %20, and & becomes %26. The result is a string that any URL parser will accept without choking.
Examples
Simple XML Element
Passing a single user record as a query parameter in an API call.
<user><name>Alice</name></user>
%3Cuser%3E%3Cname%3EAlice%3C%2Fname%3E%3C%2Fuser%3E
SOAP Envelope Snippet
You need to embed a SOAP request body into a redirect URL for a testing proxy. The namespace prefixes and colons all need encoding.
<soap:Body><GetPrice xmlns="http://example.com"/></soap:Body>
%3Csoap%3ABody%3E%3CGetPrice%20xmlns%3D%22http%3A%2F%2Fexample.com%22%2F%3E%3C%2Fsoap%3ABody%3E
XML with Special Characters & Attributes
A config fragment with attributes, ampersands in text content, and mixed quoting. This is the kind of messy real-world XML that trips people up when they try manual encoding.
<item id="5" type="sale">Price & Tax</item>
%3Citem%20id%3D%225%22%20type%3D%22sale%22%3EPrice%20%26amp%3B%20Tax%3C%2Fitem%3E
Who Uses This
Embedding XML payloads in API query strings or redirect URLs during integration work.
Building test URLs with XML parameters to feed into automated test suites or Postman collections.
Encoding XML config snippets for use in CI/CD pipeline variables or webhook URLs.
Seeing exactly how URL encoding transforms each XML character — useful when learning about web protocols.
Common Mistakes
URL encoding turns < into %3C. XML entity encoding turns it into <. They solve different problems. If you’re putting XML inside a URL, you want percent-encoding. If you’re putting text inside an XML document, you want entity encoding.
If your XML already contains %20 or other percent sequences, encoding it again will turn %20 into %2520. The receiving side will decode it back to %20 instead of a space. Only encode raw XML — not XML that’s already been through a round of encoding.
JavaScript has two functions and they are not interchangeable. encodeURI leaves characters like :, /, ?, and & alone — which is exactly what you don’t want when encoding XML for a parameter value. This tool uses encodeURIComponent, which encodes everything it should.
Technical Details
- Processing: 100% client-side — no server requests
- Browser Support: Chrome, Firefox, Safari, Edge
- Encoding Standard: RFC 3986 percent-encoding via
encodeURIComponent - Input Limit: None (limited only by your browser’s available memory)
Frequently Asked Questions
Why can’t I just paste XML directly into a URL?
URLs have a strict set of allowed characters defined by RFC 3986. Characters like <, >, &, and spaces aren’t in that set. If you drop raw XML into a URL, the browser or server will misinterpret those characters — an & starts a new query parameter, a space terminates the URL, and angle brackets may get stripped entirely.
Does my XML need to be well-formed before encoding?
Nope. The encoder doesn’t parse your XML — it treats the whole thing as a plain string and encodes every unsafe character. That said, if the server on the other end expects valid XML after decoding, it will reject malformed content. The encoding itself doesn’t care though.
What is the difference between URL encoding and XML entity encoding?
Two completely different things. URL encoding converts characters to percent sequences (%3C, %26) so they’re safe inside URLs. XML entity encoding converts characters to entity references (<, &) so they’re safe inside XML documents. You’d use URL encoding to put XML in a URL, and entity encoding to put text inside XML. Mixing them up is a common source of bugs.
How do I decode URL-encoded XML back to normal?
In JavaScript, use decodeURIComponent(). In Python, it is urllib.parse.unquote(). Most languages have an equivalent built-in function. Or you can use a URL decode tool online — paste the encoded string and get your original XML back.
Is my XML data safe when using this tool?
Yes. All encoding happens right in your browser using JavaScript. Nothing gets sent to a server — ever. You can disconnect from the internet before using it, and it’ll still work. Check your browser’s network tab if you want proof.