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

> Documentation Index  
> Fetch the complete documentation index at: https://edgetunnel-b2h.pages.dev/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-12598)
* [  TypeScript ](#tab-panel-12599)
* [  Python ](#tab-panel-12600)
* [  Rust ](#tab-panel-12601)
* [  Hono ](#tab-panel-12602)

**JavaScript**

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

[Run Worker in Playground](https://workers.cloudflare.com/playground#LYVwNgLglgDghgJwgegGYHsHALQBM4RwDcABAEbogB2+CAngLzbPYZb6HbW5QDGU2AAwAWAByiAbMIDMAVjkBGBQC4WLNsA5wuNPgJHipcxQoCwAKADC6KhACmt7ABEoAZxjpXUaDeUkNeATEJFRwwHYMAERQNHYAHgB0AFaukaSoUGAOYRHRsYkpkRbWtg4Q2AAqdDB2fnAwMGB8BFA2yElwAG5wrrwIsBAA1MDouOB2FhbxHkgkuHaocOAQJADe5iQkPXRUvP52ELwAFgAUCHYAjiB2rhAAlGsbmyS8NrckRxDAYCQMJAAGAB4AIROADylgqAE0AAoAUQ+XzAAD4nptARRcHRUc9noCjgpkQAJOxgMDoEgAdUwYFwgOQBJxuJIgJgyIqRzcJGAiAA1iAYCQAO49EgAcwcdgQBDsuHIdC2JEs5JAuFQYEQdipmF5UoS9LZaJZyEx2P+RHMRvOEBACCoITsQpIACUbh4qK47CdPt8ADSPZkfOxweYIVx+daBzaRV6lRwQap2SJ+SL2OIoH1gIjHRCeiAMACqFQAYthRJFfUbNgBfSu46t3C01yvVogWNTMDRaHQ8fhCMSSGTyWRKYo2eyOFzuTzeVpUPwBLSkULhKLhQhaNL+TLZVeRMjkshFKzjsqVRN1BpNXgtNopGyTcyrSI8mIAfRGYyyyby8wKqWrdsOy7IIez0ftDCHExmAsIA)

**TypeScript**

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

**Python**

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

**TypeScript**

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

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://edgetunnel-b2h.pages.dev/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://edgetunnel-b2h.pages.dev/workers/examples/return-html/","inLanguage":"en","image":"https://edgetunnel-b2h.pages.dev/dev-products-preview.png","dateModified":"2026-04-23","publisher":{"@type":"Organization","name":"Cloudflare","url":"https://www.cloudflare.com/"},"isPartOf":{"@type":"WebSite","@id":"https://edgetunnel-b2h.pages.dev/#website","name":"Cloudflare Docs","url":"https://edgetunnel-b2h.pages.dev/"},"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"}}]}
```
