What is MIME type "text/turtle"?

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

text/turtle is the MIME type for a compact RDF data format. It uses a simple, human-readable syntax to express data in triples.

Files in this format usually carry the extension TTL.

text/turtle turns complex relationships into simple text. It is supported by many data tools and libraries. More details can be found at W3C Turtle Specification.

Associated file extensions

Usage Examples

HTTP Header

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


    Content-Type: text/turtle    
  

HTML

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


    <a href="file.dat" type="text/turtle">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/turtle');    
      res.end('Content here');    
    }).listen(3000);    
  

Associated file extensions

FAQs

How do I configure Apache to serve .ttl files with the correct MIME type?

To ensure your Apache server sends the correct header, add the line AddType text/turtle .ttl to your .htaccess file or the main server configuration. This helps Semantic Web clients and crawlers identify the content as RDF data rather than generic text.

What is the correct Nginx configuration for text/turtle?

You should add the mapping text/turtle ttl; to your mime.types file or inside the types { ... } block in your Nginx config. If this is missing, Nginx may serve the file as application/octet-stream or text/plain, which can cause issues for automated RDF parsers.

Can web browsers display text/turtle files natively?

Most modern browsers will display the file simply as raw text because the MIME type starts with text/. Browsers do not natively render the RDF graph structure; to visualize the data, you need a browser extension or a dedicated tool like Protégé.

How does text/turtle differ from application/rdf+xml?

While both formats represent RDF data, text/turtle is designed to be compact and human-readable, making it easier to write and debug manually. In contrast, application/rdf+xml is more verbose and harder for humans to parse, though it was the original standard for XML-based toolchains.

How do I open and edit a text/turtle file?

Since the format is plain text, you can use any simple editor like Notepad, TextEdit, or VS Code. For syntax highlighting and validation, it is recommended to install a plugin specifically for RDF or Turtle syntax.

Are there any security risks associated with text/turtle?

The text/turtle format is data-centric and non-executable, making it generally safe to open. However, as with any data format, applications parsing untrusted .ttl files should be patched against buffer overflows or denial-of-service attacks caused by maliciously malformed triples.

What should I do if a validator rejects my text/turtle file?

Check for common syntax errors such as missing periods . at the end of triples or incorrect prefix definitions (@prefix). You can use online tools like the W3C RDF Validator or command-line tools like Apache Jena's riot to pinpoint the exact line causing the error.

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.