THE GITHTML FIELD GUIDE

Why raw.githubusercontent.com shows HTML as plain text

raw.githubusercontent.com currently serves .html files with a text/plain content type, an X-Content-Type-Options nosniff header, and a sandboxing content security policy. Browsers therefore display the markup as text and will not run it as a page. The fix is not a different raw URL; use a reader or host that is meant to render HTML.

Confirm the symptom with headers

A response that displays tags can result from a text/plain content type even when its HTML is valid. Check the actual response headers and status before changing the file. Separately test the document locally to distinguish a delivery-header issue from broken markup; a plain-text response alone does not prove the document is otherwise complete.

A public HTML file checked on November 21, 2026 returned text/plain with a UTF-8 charset, nosniff, and a policy beginning with default-src 'none' plus sandbox. The content type and nosniff explain plain-text display. The content security policy separately restricts capabilities and resource loading; a restrictive CSP is not, by itself, a rule that turns HTML into source text.

bash
curl -sI https://raw.githubusercontent.com/OWNER/REPO/main/docs/report.html \
  | grep -iE 'content-type|x-content-type-options|content-security-policy'

# Typical result (observed behavior, may change):
# content-type: text/plain; charset=utf-8
# x-content-type-options: nosniff
# content-security-policy: default-src 'none'; style-src 'unsafe-inline'; sandbox

What each header does

Content-Type tells the browser what the bytes are. With text/plain, the browser chooses its plain-text viewer. Older browsers sometimes guessed and rendered HTML anyway; the nosniff header, defined in the Fetch standard and described on MDN, tells the browser not to second-guess the declared type.

The content security policy is a separate boundary. In the observed response, default-src 'none' restricts resource categories that lack a more specific directive. An explicit style-src 'unsafe-inline' permits inline styles, while sandbox restricts scripts, origin behavior, forms, and other capabilities unless corresponding permissions are present. Inspect the complete policy rather than assuming that one directive describes every exception.

Avoid these dead ends

People often try appending query strings, swapping branches, or changing the file extension. None of those change the headers. Browser extensions that rewrite response headers can force rendering locally, but they weaken a protection for every page that matches the rule. Public proxy sites that re-serve raw files with an HTML type work only for public repositories and route your document through an unknown server.

  1. Do not paste private-repository raw URLs containing tokens into third-party previewers.
  2. Do not install header-rewriting extensions just to read documentation.
  3. Do not rename report.html to report.htm or add query parameters expecting a new content type.

Routes that do render

Clone the repository and open the file locally, or serve the folder with a small local server when the document uses root-relative paths. On iPhone and iPad, gitHtml lists .html files from repositories you connect and renders them with WebKit, with JavaScript and remote resources off by default. For public distribution, use a hosting service and accept its deployment model deliberately.

When you control the document, make it resilient to any of these routes: keep essential CSS inline, embed or describe key images, and put the meaningful text in the HTML body rather than generating it at runtime.

Sources and further reading

AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.

All html troubleshooting guides →

Read as MarkdownAll guides

Why raw.githubusercontent.com shows HTML as plain text · gitHtml