devkult_
tools29converters34
home/mime/.xml

.xml MIME type

XMLtext & code

application/xml

XML documents. application/xml is preferred; text/xml is an equivalent alias.

MIME typeapplication/xml
Extensions.xml
Also seen astext/xml
Content-Typeapplication/xml; charset=utf-8
Compress in transit?Yes — enable gzip or Brotli

Good to know

  • RSS and Atom feeds have their own types — application/rss+xml and application/atom+xml — though many feeds are served as application/xml.
  • The encoding declared in <?xml version="1.0" encoding="…"?> should agree with the charset in the header.

Serve .xml files with the right type

The response header to send:

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

Most servers pick the type from the file extension. If yours sends the wrong one, map it explicitly:

nginx (inside the types block in mime.types)
application/xml xml;
Apache (.htaccess or server config)
AddType application/xml .xml
Express
res.set("Content-Type", "application/xml; charset=utf-8");
Python
import mimetypes

mimetypes.add_type("application/xml", ".xml")
HTML file input
<input type="file" accept=".xml,application/xml">

Check it

See what a server sends for a file, and what type a local file really is by its contents:

curl -sI https://example.com/file.xml | grep -i '^content-type:'
file --mime-type file.xml

Frequently asked questions

What is the MIME type for .xml files?

application/xml. You may also see text/xml, but application/xml is the one to send.

What Content-Type header should a .xml file be served with?

Content-Type: application/xml; charset=utf-8. As a text format, include the charset so browsers don't guess the encoding. It compresses well, so let the server apply gzip or Brotli.

Related types

Headers that go with it: Content-Type · Content-Disposition · X-Content-Type-Options