Markdown access

View as Markdown

Fern serves clean Markdown for any documentation page — including API Reference pages — so agents can consume your content efficiently. Agents fetch the source by appending .md or .mdx to a page URL, or by sending an Accept: text/markdown header via content negotiation. Combined with llms.txt, this reduces token consumption by 90%+ compared to HTML.

Example showing a page's underlying Markdown

For example, https://buildwithfern.com/learn/docs/ai-features/markdown.md displays the Markdown source for this page.

The same Markdown is used everywhere — single pages, llms.txt, and llms-full.txt — and respects the same <llms-only> and <llms-ignore> content controls.

A default per-page directive is automatically prepended to every page’s Markdown output when served to AI agents, pointing them to your .md URLs, llms.txt, and llms-full.txt. You can override or disable this directive in docs.yml. The directive is only visible to agents — human-facing documentation is unaffected.

Interactive components in Markdown output

Interactive components such as <EndpointRequestSnippet>, <EndpointResponseSnippet>, and <EndpointSchemaSnippet> render as fenced code blocks and structured content in the Markdown output, so agents receive the full request and response examples without parsing HTML.

Accessing protected docs

On sites with authentication enabled, agents must include a JWT on every Markdown request — whether for an individual page, llms.txt, or llms-full.txt. Exchange your Fern API key for a JWT:

Get a JWT
$curl https://docs.example.com/api/fern-docs/get-jwt \
> -H "FERN_API_KEY: $FERN_TOKEN"
$# → { "fern_token": "eyJ...", "roles": [] }

Send the returned JWT as the FERN_TOKEN header on subsequent requests:

Fetch protected content
$curl https://docs.example.com/platform/overview \
> -H 'Accept: text/markdown' \
> -H "FERN_TOKEN: $JWT"

JWTs are valid for 30 days — cache and refresh as needed.

Markdown for troubleshooting

Viewing the Markdown directly is also useful for troubleshooting layout problems. A View as Markdown button is enabled by default on every page and can be configured through the page actions configuration.