Prompt Buddy logoPrompt Buddy

cloudflare · Cloudflare Workers Docs

Workers Return JSON

Demonstrates how to configure a Cloudflare Worker to return a JSON response body using various programming languages including JavaScript, TypeScript, Python, and Rust.

Import to Prompt Buddy

Derived skill

Files assembled from official documentation

Viewing SKILL.md

Workers Return JSON

Demonstrates how to configure a Cloudflare Worker to return a JSON response body using various programming languages including JavaScript, TypeScript, Python, and Rust.

When To Use

Use when you need to implement a Cloudflare Worker that serves as an API endpoint by returning structured JSON data to a client.

Reference Files

FileContainsUse For
SKILL.mdEntry point: scope, routing table, and workflow.Start here.
docs/workers-examples-return-json-workflow-guide.mdA markdown guide demonstrating how to return JSON responses directly from a Cloudflare Worker script.Questions about a markdown guide demonstrating how to return JSON responses directly from a Cloudflare Worker script.
examples/workers-examples-return-json-cloudflare-workers-return-json-javascript.textA JavaScript code example demonstrating how to use the Response.json() method within a Cloudflare Worker to return a JSON object.Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating how to use the Response.json() method within a Cloudflare Worker to return a...
examples/workers-examples-return-json-cloudflare-workers-return-json-javascript-2.textA JavaScript code example demonstrating how to use the Response.json method to return a JSON object from a Cloudflare Worker.Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating how to use the Response.json method to return a JSON object from a Cloudflare...
examples/workers-examples-return-json-cloudflare-workers-python-return-json.textA Python implementation of a Cloudflare Worker that returns a JSON response using the WorkerEntrypoint class.Exact payloads, commands, or snippets shown in A Python implementation of a Cloudflare Worker that returns a JSON response using the WorkerEntrypoint class.
examples/workers-examples-return-json-cloudflare-workers-rust-return-json.textA Rust code example demonstrating how to use the serde crate to serialize a struct into a JSON response within a Cloudflare Worker.Exact payloads, commands, or snippets shown in A Rust code example demonstrating how to use the serde crate to serialize a struct into a JSON response within a Clou...
examples/workers-examples-return-json-cloudflare-workers-hono-return-json.textA Hono framework implementation for a Cloudflare Worker that returns a JSON response.Exact payloads, commands, or snippets shown in A Hono framework implementation for a Cloudflare Worker that returns a JSON response.

What This Skill Covers

  • Return JSON directly from a Worker script, useful for building APIs and middleware.
  • Main sections: Tags.

Workflow

  1. Open the most relevant file under docs/ for the exact documented workflow and wording.
  2. Open schemas/ files for exact structured contracts.
  3. Open examples/ files for concrete requests, commands, snippets, and manifests.
  4. Do not add behavior or configuration that is not present in the attached source files.

Canonical source: https://developers.cloudflare.com/workers/examples/return-json