---
description: Deliver an HTML page from an HTML string directly inside the Worker script.
title: Return small HTML page
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers/llms.txt  
> Use this file to discover all available pages before exploring further.

# Return small HTML page

Deliver an HTML page from an HTML string directly inside the Worker script.

Last updated Aug 24, 2026|Copy as Markdown|[View as Markdown](https://fix-ai-gateway-guardrails-streaming-docs.previews.developers.cloudflare.com/workers/examples/return-html/index.md)|[Agent setup](https://fix-ai-gateway-guardrails-streaming-docs.previews.developers.cloudflare.com/agent-setup/)

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/return-html)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

```js
export default {
  async fetch(request) {
    const html = `<!DOCTYPE html>
		<body>
		  <h1>Hello World</h1>
		  <p>This markup was generated by a Cloudflare Worker.</p>
		</body>`;

    return new Response(html, {
      headers: {
        "content-type": "text/html;charset=UTF-8",
      },
    });
  },
};
```

```ts
export default {
	async fetch(request): Promise<Response> {
		const html = `<!DOCTYPE html>
		<body>
		  <h1>Hello World</h1>
		  <p>This markup was generated by a Cloudflare Worker.</p>
		</body>`;

		return new Response(html, {
			headers: {
				"content-type": "text/html;charset=UTF-8",
			},
		});
	},
} satisfies ExportedHandler;
```

```py
from workers import WorkerEntrypoint, Response

class Default(WorkerEntrypoint):
    async def fetch(self, request):
        html = """<!DOCTYPE html>
        <body>
          <h1>Hello World</h1>
          <p>This markup was generated by a Cloudflare Worker.</p>
        </body>"""

        headers = {"content-type": "text/html;charset=UTF-8"}
        return Response(html, headers=headers)
```

```rs
use worker::*;

#[event(fetch)]
async fn fetch(_req: Request, _env: Env, _ctx: Context) -> Result<Response> {
    let html = r#"<!DOCTYPE html>
		<body>
		  <h1>Hello World</h1>
		  <p>This markup was generated by a Cloudflare Worker.</p>
		</body>
    "#;
    Response::from_html(html)
}
```

```ts
import { Hono } from "hono";
import { html } from "hono/html";

const app = new Hono();

app.get("*", (c) => {
	const doc = html`<!DOCTYPE html>
		<body>
			<h1>Hello World</h1>
			<p>This markup was generated by a Cloudflare Worker with Hono.</p>
		</body>`;

	return c.html(doc);
});

export default app;
```

Was this helpful?

YesNo

## On this page

[![](https://fix-ai-gateway-guardrails-streaming-docs.previews.developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://fix-ai-gateway-guardrails-streaming-docs.previews.developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers/examples/return-html/#page","headline":"Return small HTML page · Cloudflare Workers docs","description":"Deliver an HTML page from an HTML string directly inside the Worker script.","url":"https://developers.cloudflare.com/workers/examples/return-html/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","dateModified":"2026-08-24","publisher":{"@type":"Organization","name":"Cloudflare","url":"https://www.cloudflare.com/"},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["JavaScript","TypeScript","Python","Rust"]}
```
