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.
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
| File | Contains | Use For |
|---|---|---|
SKILL.md | Entry point: scope, routing table, and workflow. | Start here. |
docs/workers-examples-return-json-workflow-guide.md | A 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.text | A 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.text | A 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.text | A 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.text | A 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.text | A 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
- Open the most relevant file under
docs/for the exact documented workflow and wording. - Open
schemas/files for exact structured contracts. - Open
examples/files for concrete requests, commands, snippets, and manifests. - 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
