What is MIME type "text/markdown"?

A MIME type is a string that tells browsers and other tools how to handle a particular kind of file.

The MIME type text/markdown tells programs that the file contains plain text enhanced with Markdown formatting. It signals simple symbols are embedded to indicate headings, links, lists, and other text structure. Use of this type means the content can be easily converted to HTML or other formats. Files marked as text/markdown commonly use extensions such as MD, MARKDOWN, MKD, MARKDN, MDOWN, MDTEXT, and MDTXT.

Associated file extensions

Usage Examples

HTTP Header

When serving content with this MIME type, set the Content-Type header:


    Content-Type: text/markdown    
  

HTML

In HTML, you can specify the MIME type in various elements:


    <a href="file.dat" type="text/markdown">Download file</a>    
  

Server-side (Node.js)

Setting the Content-Type header in Node.js:


    const http = require('http');    
    
    http.createServer((req, res) => {    
      res.setHeader('Content-Type', 'text/markdown');    
      res.end('Content here');    
    }).listen(3000);    
  

Associated file extensions

FAQs

Is text/markdown the official MIME type for Markdown files?

Yes, text/markdown is the official media type registered with the IANA (RFC 7763) in 2016. Before this standardization, developers often used unofficial types like text/x-markdown, but you should now exclusively use text/markdown for maximum compatibility.

How do I configure Apache to serve .md files correctly?

To serve .md files with the correct MIME type in Apache, add a directive to your .htaccess file or main configuration. Use the line AddType text/markdown .md .markdown to ensure browsers and clients recognize the content type.

Why does my browser download .md files instead of displaying them?

Browsers often download these files if the server sends them as application/octet-stream or if the browser lacks a built-in renderer for Markdown. To force display, ensure your server sends the text/markdown header, though users may still need a browser extension to see rendered formatting instead of raw text.

What is the difference between text/markdown and text/x-markdown?

The text/x-markdown type was a common convention before the official standard existed (the x- prefix indicates experimental or non-standard types). specific applications may still default to the old version, but modern web servers and applications should prioritize the standard text/markdown.

How do I add Markdown support to Nginx?

You can add the MIME type to your mime.types file or directly inside your server block configuration. Add the line text/markdown md; inside the types { } block to associate the extension with the correct content type.

Are there security risks with serving text/markdown?

The file type itself is safe plain text, but security issues arise when converting it to HTML. If your application renders user-submitted Markdown, it must sanitize the output to prevent Cross-Site Scripting (XSS), as standard Markdown allows raw HTML and javascript links.

Should I use text/plain instead of text/markdown?

While text/plain ensures the file is readable in a browser, it loses the semantic meaning of the file. Using text/markdown is better because it informs the client software that the text follows specific formatting rules, allowing IDEs and viewers to apply syntax highlighting automatically.

General FAQ

What is a MIME type?

A MIME (Multipurpose Internet Mail Extensions) type is a standard that indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.

MIME types are important because they help browsers and servers understand how to process a file. When a browser receives a file from a server, it uses the MIME type to determine how to display or handle the content, whether it's an image to display, a PDF to open in a viewer, or a video to play.

MIME types consist of a type and a subtype, separated by a slash (e.g., text/html, image/jpeg, application/pdf). Some MIME types also include optional parameters.

How do I find the MIME type for a file?

You can check the file extension or use a file identification tool such as file --mime-type on the command line. Many programming languages also provide libraries to detect MIME types.

Why are multiple MIME types listed for one extension?

Different applications and historical conventions may use alternative MIME identifiers for the same kind of file. Showing them all helps ensure compatibility across systems.