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

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

[Skip to content](#%5Ftop) 

# Return small HTML page

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

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.

* [  JavaScript ](#tab-panel-12057)
* [  TypeScript ](#tab-panel-12058)
* [  Python ](#tab-panel-12059)
* [  Rust ](#tab-panel-12060)
* [  Hono ](#tab-panel-12061)

JavaScript

```
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",      },    });  },};
```

[Run Worker in Playground](https://workers.cloudflare.com/playground#LYVwNgLglgDghgJwgegGYHsHALQBM4RwDcABAEbogB2+CAngLzbPYZb6HbW5QDGU2AAwAOAJzCArAGZhANgAswxQC4WLNsA5wuNPgJHjpcxYoCwAKADC6KhACmt7ABEoAZxjpXUaDeUkNeATEJFRwwHYMAERQNHYAHgB0AFaukaSoUGAOYRHRsYkpkRbWtg4Q2AAqdDB2fnAwMGB8BFA2yElwAG5wrrwIsBAA1MDouOB2FhbxHkgkuHaocOAQJADe5iQkPXRUvP52ELwAFgAUCHYAjiB2rhAAlGsbmyS8NrckRxDAYCQMJAAGAB4AIROADylgqAE0AAoAUQ+XzAAD4nptARRcHRUc9noCjgBGZEACTsYDA6BIAHVMGBcIDkIScbiSICYMiKkc3CRgIgANYgGAkADuPRIAHMHHYEAQ7LhyHQtiRLBSQLhUGBEHZqZg+dKEgz2WjWchMdj-kRzMbzhAQAgqCE7MKSAAlG4eKiuOwnT7fAA0jxZHzscHmCFcfnWQc2kVepUcEGqdkifki9jiKF9YCIx0QXogDAAqhUAGLYYSRP3GzYAXyruJrd0ttarNaIFjUzA0Wh0PH4QjEkhkCiUwmKNnsjhc7k83laVD8AS0pFC4Si4UIWjS-ky2TXkTIFLIRSsE7KlSTdQaTV4LTaKRsk3Mq0ivJiAH0RmMsim8vMCqkNYdp23ZBL2egDoYw4mMIzAWEAA)

TypeScript

```
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;
```

Python

```
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)
```

```
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)}
```

TypeScript

```
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;
```

```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/dev-products-preview.png","dateModified":"2026-04-23","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"]}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"item":{"@id":"/directory/","name":"Directory"}},{"@type":"ListItem","position":2,"item":{"@id":"/workers/","name":"Workers"}},{"@type":"ListItem","position":3,"item":{"@id":"/workers/examples/","name":"Examples"}},{"@type":"ListItem","position":4,"item":{"@id":"/workers/examples/return-html/","name":"Return small HTML page"}}]}
```
