Markdown access

View as Markdown

Fern serves clean Markdown for any documentation page 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.

.md and .mdx URLs resolve for every routable page, including API Reference endpoint pages that don’t appear in the navigation, sitemap.xml, or llms.txt. Any URL that renders as HTML returns its Markdown twin.

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 and llms.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 and llms.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.

Redirects

The redirects configured in docs.yml apply to Markdown URLs. A redirected page’s .md or .mdx twin returns a 308 to the destination’s twin, preserving the requested extension: /old/page.md redirects to /new/page.md, and /old/page.mdx to /new/page.mdx.

Missing pages

When an agent requests a .md URL that matches no page and no redirect, the response includes up to three suggested pages under a ## Similar pages heading, each linking to the closest matching .md source. This mirrors the “Were you looking for one of these?” suggestions human readers see on the 404 page.

Accessing protected docs

On sites with authentication enabled, agents must include a JWT on every Markdown request — whether for an individual page or llms.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.