Skip to content

llms.txt Markdown Format: 5 Writing Techniques to Reduce AI Token Consumption by 30%

Karmaşık HTML ve optimize edilmiş Markdown dosyasının karşılaştırmalı illüstrasyonu

When an AI agent crawls your website, it has to parse through the entire HTML structure, JavaScript snippets, and ad slots to make sense of your content. Even though models like GPT-4o or Claude 3.5 have large context windows, every unnecessary character increases processing costs and makes it harder for the model to focus on the actual information.

The Short Answer: llms.txt is a file located in the root directory of a website that presents site content in an optimized, low-density Markdown format for AI models. By stripping away unnecessary HTML tags and visual clutter, this file ensures the AI focuses solely on the data, reducing token consumption by an average of 30%.

Why Should You Use llms.txt?

Traditional web pages are designed for humans; they contain colors, fonts, and complex layouts. However, for an AI crawler (bot), a <div class="main-content"> tag is just 28 characters of noise. The llms.txt standard eliminates this noise, reducing content to pure Markdown. This not only saves costs but also reduces the risk of the AI hallucinating or misinterpreting your content.

1. Semantic Markdown Usage and Cleaning Unnecessary Formatting

For AI models, bold or italicized words often do not create a semantic difference. During the tokenization process (e.g., OpenAI's tiktoken library), every asterisk (*) or underscore (_) can count as an additional token. Especially in technical documentation, reserve Markdown characters used for emphasis only for hierarchy (headings).

For example, when creating a list, using flat hierarchical headings instead of complex nested lists helps the AI process the data faster. Using H1, H2, and H3 tags in a logical flow helps the model understand the "skeleton" of the content in a single pass.

2. The Power of URL Shortening and Relative Paths

When it comes to AI token optimization, URLs are the biggest hidden expense. Instead of writing the full protocol (https://www.site.com/...) for every link in an llms.txt file, define the file structure using relative paths. Since AI agents know the root directory where the file is located, they can easily resolve the [Contact](/contact) format.

This technique saves thousands of tokens, especially in llms-full.txt files that provide a sitemap for hundreds of pages. Remember, for GPT-4o, every 1000 tokens is a cost, and long URLs fill that limit quickly.

3. Noise Filtering: Removing Boilerplate and Navigation

Text that repeats on every page, such as "About Us," "Social Media," or "Terms of Service" found in the footer or side menus of websites, is a complete waste of resources for an AI. Leave only the main content in your llms.txt file. If you are sharing an article, do not include the author's biography or a popular posts widget in this file.

Technically, the most efficient approach is to divide the content into these sections:
1. Title and Short Summary
2. Main Body (Pure text)
3. Related Technical Resources (Links)

4. Structured Data Presentation with YAML Frontmatter

A small YAML block added to the top of your Markdown file allows the AI to understand the scope of the content in seconds. This block enables the model to answer the question "is this content useful to me?" before reading the entire text.

---
title: AI Token Optimization
date: 2024-05-20
tags: [SEO, AI, Markdown]
complexity: intermediate
---

This structure makes it easier for the AI agent to categorize the data without needing to search for this information within the free text.

5. Recursive Summarization Strategy

If your website is very large, a single llms.txt file might not be sufficient. In this case, apply the "hub and spoke" model. Provide a short summary of each main category in your main /llms.txt file and link to that category's own Markdown file (e.g., /guides/llms.txt) for more detailed information. This minimizes total token costs by allowing the AI to dive only as deep as it needs.

Technical Checklist

  • Ensure the file is in the root directory (domain.com/llms.txt).
  • Check that the content is encoded in UTF-8.
  • Establish a consistent structure from H1 to H4 in the Markdown hierarchy.
  • Keep image descriptions (alt text) only if they are informative; delete decorative images.
  • Ensure your robots.txt file allows access to the llms.txt file.

Example Scenario: Inefficient vs. Optimized Markdown

Below, you can see the transformation of a product page within llms.txt:

Bad Example (Noisy):
# Product Name: Super Robot V1 **Price:** 500 USD (VAT included) [Click Here to Buy](https://www.site.com/cart/add/product-id-123) *This product is amazing, you must buy it!*
(Side menu: Home, Products, Contact...)

Optimized Example (llms.txt Standard):
# Super Robot V1 - Price: 500 USD - SKU: SR-V1 - Summary: Home cleaning robot. [Buy Now](/cart?id=123)

Common Mistakes

  • Over-shortening: Deleting so many words that the meaning is lost causes the AI to generate incorrect information.
  • Image Links: Putting links to large image files inside llms.txt does not mean anything to an AI (except for multimodal models).
  • Outdated Files: Leaving the llms.txt file static when your site changes leads the AI to process stale data.

Frequently asked questions

Does the llms.txt file affect my Google ranking?

It is not a direct Google ranking factor, but it helps you receive AI-powered traffic by ensuring that AI search engines like Perplexity, ChatGPT, and Claude crawl your site correctly.

Does this file replace robots.txt?

No, robots.txt tells crawlers where they can go; llms.txt optimizes what and how they read once they get there. They should work together.

Wouldn't it be better to use JSON instead of Markdown?

LLMs (Large Language Models) understand the Markdown format very well, just like natural language. JSON is more rigid; Markdown strikes the best balance between readability and token efficiency for both humans and models.

Scan your site for free