application/xml vs text/xml — XML MIME Types Explained

Understand the difference between application/xml and text/xml, when to use each, and how they relate to XHTML and other XML-based formats.

Application Types

Detailed Explanation

XML MIME Types

XML content can be served with two MIME types: application/xml and text/xml. Both are valid, but they have important differences.

text/xml

text/xml was defined in RFC 3023. Under this type, the character encoding defaults to US-ASCII if no charset parameter is provided. This can cause problems with non-ASCII content.

Content-Type: text/xml; charset=utf-8

application/xml

application/xml defaults to UTF-8 if no charset is specified (per the XML specification). This makes it safer for international content.

Content-Type: application/xml

Which Should You Use?

RFC 7303 (2014) updated the rules and recommends application/xml as the preferred type. The key differences:

Feature text/xml application/xml
Default charset US-ASCII UTF-8
Safe for non-ASCII Only with explicit charset Yes
XML declaration honored Only with explicit charset Always
Recommended Legacy use Yes (RFC 7303)

XML-Based Subtypes

Many formats use XML underneath and have their own MIME types:

MIME Type Format
application/xhtml+xml XHTML
application/atom+xml Atom feeds
application/rss+xml RSS feeds
image/svg+xml SVG images
application/vnd.openxmlformats-officedocument.* Office XML

Use Case

Use application/xml as the default for XML APIs and configuration files. Only use text/xml for legacy systems that require it. Always include charset=utf-8 when using text/xml to avoid encoding issues with non-ASCII characters.

Try It — MIME Type Reference

Open full tool