text/xml means: text/xml is the legacy media type for XML documents treated primarily as text. It predates application/xml and is still emitted by older systems and SOAP 1.1 services. RFC 7303 documents both and explains their differing default charset behavior. Text media types carry human-readable character data. Because they are text, the charset parameter matters: without an explicit charset=utf-8, receivers may guess a legacy encoding and mangle non-ASCII characters. Text types are also the ones browsers render or display inline, so the subtype decides whether content is treated as markup, code, or plain prose. You will encounter text/xml in contexts such as soap 1.1 envelopes from legacy web services; older xml apis and tools that hardcode text/xml; xml documents where the producer treats the payload as plain text. It is commonly associated with the file extension(s) .xml. The practical difference from application/xml is the default encoding when no charset is given: text/xml defaults to us-ascii per RFC 7303, while application/xml lets the XML prolog drive detection. Declare charset explicitly to avoid surprises.
When you'll see text/xml
- SOAP 1.1 envelopes from legacy web services
- Older XML APIs and tools that hardcode text/xml
- XML documents where the producer treats the payload as plain text
How to handle it
When serving a text type, always declare charset=utf-8 unless the specification fixes another encoding, and escape or sanitize content according to how it will be rendered. Treat text/html as executable: never inject untrusted strings into it without encoding. For text/plain and text/csv, preserve line endings and quoting rules so downstream parsers do not split fields incorrectly, and set Content-Disposition when you want a download instead of inline display. As a final checklist for text types: declare charset=utf-8 everywhere, normalize line endings for cross-platform consumers, escape output for the rendering context to prevent injection, and set Content-Disposition deliberately so browsers either display inline or download rather than guessing.
Notes & gotchas
The practical difference from application/xml is the default encoding when no charset is given: text/xml defaults to us-ascii per RFC 7303, while application/xml lets the XML prolog drive detection. Declare charset explicitly to avoid surprises.
Examples
POST /v1/resource HTTP/1.1
Host: api.example.com
Content-Type: text/xml; charset=utf-8
Content-Length: 33
<root><item>example</item></root> curl -i -X POST -H "Content-Type: text/xml; charset=utf-8" --data-binary @payload https://api.example.com/v1/resource const res = await fetch("/v1/resource", { headers: { Accept: "text/xml" } });
// verify res.headers.get("Content-Type") starts with "text/xml"
const text = await res.text(); // handle according to the declared type import requests
with open("payload", "rb") as fh:
res = requests.post("https://api.example.com/v1/resource", data=fh,
headers={"Content-Type": "text/xml; charset=utf-8"}, timeout=30) Frequently asked questions
Is text/xml deprecated?
It is legacy but still valid and widely understood. New systems should prefer application/xml; keep text/xml only when interoperating with older SOAP 1.1 or XML-RPC endpoints.
Why does my text/xml payload show garbled accents?
Because no charset was declared and the receiver assumed us-ascii. Add ; charset=utf-8 and ensure the XML prolog encoding matches.
Do I need to specify charset for text types?
Yes — append ; charset=utf-8 unless the type defines its own encoding rules. Without it, receivers may fall back to a legacy encoding and corrupt non-ASCII characters. UTF-8 is the safe default for the modern web.
What is the difference between text/plain and text/html?
text/plain is displayed verbatim with no markup interpretation; text/html is parsed as a document, executing styles and scripts. Serving user content as text/html when you meant plain text is a cross-site scripting risk.
Why do my non-ASCII characters appear corrupted?
The receiver guessed the wrong encoding because no charset was declared. Send charset=utf-8 in the Content-Type, ensure the bytes are actually UTF-8, and for HTML add a matching meta charset tag.
Try the JSON Formatter
Beautify, validate and minify JSON with clear error messages.