DevToolsmith

YAML MIME Type

application/yaml is the MIME type for YAML files. Here is the Content-Type header to send, the file signature, and how to configure servers and code.

MIME type
application/yaml
Extensions
.yaml, .yml
Content-Type header
application/yaml; charset=utf-8
Registered
Yes, with IANA
Compress with gzip
Yes, it is text or uncompressed
Category
Data and text

About YAML files

YAML only got a registered type in 2024 (RFC 9512). Before that, servers and tools used text/yaml, text/x-yaml and application/x-yaml, and you will still meet all three. Browsers show YAML as text or download it, depending on the type they receive.

Other types seen for these files: text/yaml , text/x-yaml , application/x-yaml . Accept them when reading uploads, but send application/yaml yourself.

File signature

YAML has no fixed signature: it is text without a magic number, so validate uploads by parsing the content rather than by checking bytes.

Serve .yaml with the right Content-Type

Response header
Content-Type: application/yaml; charset=utf-8
nginx (a line in the types { } block of mime.types)
application/yaml yaml yml;
Apache (.htaccess or server config)
AddType application/yaml .yaml .yml
AddCharset UTF-8 .yaml .yml
Caddy
@yaml path *.yaml *.yml
header @yaml Content-Type "application/yaml; charset=utf-8"
Check what a server sends
curl -sI https://example.com/file.yaml | grep -i '^content-type'
# Content-Type: application/yaml; charset=utf-8

Set the type in code

Node.js (Express)
res.set('Content-Type', 'application/yaml; charset=utf-8');
Python
import mimetypes

mimetypes.add_type('application/yaml', '.yaml')  # if your system doesn't know it
mimetypes.guess_type('file.yaml')[0]  # 'application/yaml'
Go
mime.AddExtensionType(".yaml", "application/yaml; charset=utf-8")
w.Header().Set("Content-Type", "application/yaml; charset=utf-8")

Accept .yaml uploads

HTML
<input type="file" accept=".yaml,.yml,application/yaml">

The accept attribute only filters the file picker; users can still choose another file. Listing the extension as well as the type matters, because operating systems don’t always report the type you expect.

Related types

  • .json (application/json): JSON
  • .xml (application/xml): XML
  • .txt (text/plain): Plain text

More data and text

.csv , .tsv , .md , .ndjson , .jsonld , .geojson , .ics , .sql . Look up any extension or type with the MIME type lookup.

Sources

Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.

Frequently asked questions

What is the MIME type for .yaml files?

application/yaml. You may also see text/yaml, text/x-yaml, application/x-yaml, which are older or unofficial; send application/yaml. It is a text format, so add the character set: "Content-Type: application/yaml; charset=utf-8".

Why does my server send the wrong Content-Type for .yaml?

Web servers pick the type from the file extension using a table (mime.types in nginx and Apache). If .yaml is missing from that table, they send a default such as application/octet-stream or text/plain. Add the mapping as shown on this page, then check the response with "curl -sI".

How can I check that a file really is YAML?

YAML has no fixed file signature, so the extension and content are all you have. Check that the content is what you expect, for example by parsing it, before trusting an upload.