JSON Templates for Developers — Ready-to-Use Examples for APIs, Config & DevOps
Browse practical JSON templates for REST APIs, configuration files, database schemas, and cloud infrastructure. Copy, customize, and use in your projects. 18 templates with real-world examples.
Why Use JSON Templates?
Every developer has written the same JSON structures dozens of times — an API response envelope, a tsconfig.json, a Docker Compose file. Each time, you either copy from a previous project (hoping it was correct) or write from scratch (introducing subtle mistakes).
Templates eliminate that cycle. Starting from a proven structure gives you four concrete advantages:
- Save time. Skip the blank-file problem. A template gets you to the interesting part of your work faster.
- Ensure consistency. When every service in your org returns the same API envelope, consumers can write one response handler instead of ten.
- Reduce errors. Forgetting a required field in a Kubernetes manifest can take down a deployment. Templates include the fields you would otherwise forget.
- Onboard faster. New team members can read a template and immediately understand the expected structure instead of reverse engineering it from production data.
The templates below cover the most common JSON structures in modern development. Each one is available in our Templates Library where you can copy them with a single click.
API Response Templates
The most impactful JSON template you can adopt is a consistent API response envelope. Instead of every endpoint returning ad-hoc shapes, define a standard wrapper with data on success, error on failure, and meta for request tracing and pagination.
Paginated API Response
Here is a real-world paginated response following the envelope pattern:
{
"data": [
{ "id": "usr_abc123", "name": "Alice Johnson", "role": "admin" },
{ "id": "usr_def456", "name": "Bob Smith", "role": "member" }
],
"meta": {
"total": 84,
"page": 2,
"per_page": 20,
"total_pages": 5,
"request_id": "req_9f3b7a"
}
}This structure lets clients render pagination controls from meta without guessing. The request_id makes debugging support tickets trivial — just search your logs.
Browse the full templates: REST API Success Response, REST API Error Response, Paginated Response.
Configuration File Templates
Configuration files are where most JSON errors happen silently. A wrong compiler option in tsconfig.json does not crash — it just produces subtly wrong output. Starting from a vetted template avoids that.
TypeScript Configuration
A minimal but production-ready tsconfig.json for a Next.js project:
{
"compilerOptions": {
"target": "ES2017",
"lib": ["dom", "dom.iterable", "esnext"],
"module": "esnext",
"moduleResolution": "bundler",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"jsx": "preserve",
"paths": { "@/*": ["./src/*"] }
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}The key choices here: strict: true catches type errors early, moduleResolution: "bundler" aligns with modern bundlers, and the @/* path alias keeps imports clean.
Configuration templates: package.json, tsconfig.json, ESLint Config.
Database Schema Templates
Whether you are seeding a development database or defining a document structure for MongoDB, having a template means your team agrees on field names, types, and default values before the first line of application code.
MongoDB User Document
{
"_id": "ObjectId('66a1b2c3d4e5f6a7b8c9d0e1')",
"email": "alice@example.com",
"profile": {
"firstName": "Alice",
"lastName": "Johnson",
"avatar": "https://cdn.example.com/avatars/alice.jpg"
},
"roles": ["admin", "editor"],
"settings": { "theme": "dark", "locale": "en-US" },
"createdAt": "2026-01-15T09:30:00Z",
"updatedAt": "2026-03-20T14:22:00Z"
}This structure nests related fields under profile and settings to keep the top-level document flat enough for efficient indexing while grouping logically related data.
Database templates: MongoDB Schema, Prisma Seed Data.
DevOps & Cloud Templates
Infrastructure-as-code files are some of the most error-prone JSON you will write. A missing field in a Kubernetes manifest or a CloudFormation template can cause silent failures that only surface in production. Templates give you a known-good starting point.
Kubernetes Deployment
A simplified Kubernetes deployment manifest in JSON format:
{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"name": "web-api",
"labels": { "app": "web-api", "env": "production" }
},
"spec": {
"replicas": 3,
"selector": { "matchLabels": { "app": "web-api" } },
"template": {
"metadata": { "labels": { "app": "web-api" } },
"spec": {
"containers": [{
"name": "web-api",
"image": "registry.example.com/web-api:1.4.2",
"ports": [{ "containerPort": 8080 }],
"resources": {
"requests": { "cpu": "250m", "memory": "256Mi" },
"limits": { "cpu": "500m", "memory": "512Mi" }
}
}]
}
}
}
}Resource requests and limits are included by default — skipping them is the number one cause of noisy-neighbor problems in shared clusters. The labels follow the standard app / env convention so that selectors and network policies work out of the box.
Infrastructure templates: Docker Compose, Kubernetes Deployment, GitHub Actions Workflow.
JWT Payload Template
JSON Web Tokens carry claims as a JSON payload. Getting the standard claims right is critical — a missing exp claim means tokens never expire, and a wrong iss breaks verification.
{
"sub": "usr_abc123",
"iss": "https://auth.example.com",
"aud": "https://api.example.com",
"exp": 1774648800,
"iat": 1774645200,
"nbf": 1774645200,
"roles": ["admin", "editor"],
"email": "alice@example.com"
}The registered claims (sub, iss, aud, exp, iat, nbf) follow RFC 7519. Custom claims like roles and email should use short names to keep token size small — JWTs travel in HTTP headers where every byte matters.
See the full template: JWT Payload.
How to Customize Templates
A template is a starting point, not a finished product. Here is a practical workflow for adapting any template to your project:
- Start from the closest template. Pick the one that matches your use case most closely. A paginated response template is a better starting point for a search endpoint than a generic success response.
- Rename and add fields. Change placeholder values to your actual field names. Add domain-specific fields your application needs. Remove fields that do not apply.
- Validate the result. Paste your modified JSON into our JSON Validator to catch syntax errors — a trailing comma or missing quote is easy to introduce when editing by hand.
- Format for readability. Run it through the JSON Formatter to ensure consistent indentation before committing to your codebase or sharing with your team.
- Lock it down with a schema. For critical structures like API responses, define a JSON Schema so that future changes are validated automatically.
Browse All Templates
The examples in this guide are just a sample. Our Templates Library includes 18 ready-to-use templates covering APIs, configuration, databases, authentication, and cloud infrastructure — each with field-by-field explanations and copy-to-clipboard support.
Browse the full collection: Visit the JSON Templates Library to find templates for your stack. Copy any template with one click, customize it, and validate the result with our JSON Formatter.