jsontoschema

Blog

Practical takes on schemas, types, and getting more out of your JSON.

This Blog Is Moving

We're shifting our writing to jsontotypescript.com. Here's why.

Replacing any with Generated Types in Legacy Code

Use generated TypeScript interfaces from real JSON to eliminate any types across a legacy codebase.

Diffing API Versions with Schemas

Compare two API response versions by diffing their schemas instead of wading through raw JSON.

Catching JSON Drift in CI with Schema Snapshots

Use schema snapshots to detect unexpected API response changes in your CI pipeline.

Specifying LLM Output Shape with Schemas

Use compact schemas in your prompts to tell LLMs exactly what JSON structure to return.

Compact Schemas vs JSON Schema in LLM Prompts

JSON Schema is verbose for LLM prompts. A compact schema conveys the same structure in a fraction of the tokens.

Documenting API Responses with Generated Schemas

Use generated schemas to document API endpoints faster than writing examples or specs by hand.

How Array Merging Produces Optional Fields

When JSON array items differ, schema generation merges them into one shape with optional fields.

Type-Safe Config Files from JSON Samples

Generate TypeScript interfaces from your JSON config files to catch typos and missing fields at compile time.

Typing Third-Party APIs Without Official Types

How to generate TypeScript interfaces from JSON responses when the API has no type definitions.

Reading Unfamiliar JSON with Schemas

Convert unknown API responses to schemas to understand their structure in seconds, not minutes.

Build LLM Function Schemas from Sample Data

Turn sample JSON into function-calling parameter schemas instead of writing them by hand.

Generate TypeScript Types from curl Output

Pipe API responses from curl into the jsontoschema CLI to get TypeScript interfaces in seconds.

Generated Schemas vs Zod for Runtime Validation

When to use a generated schema and when to reach for Zod for validating JSON at runtime.

Why LLMs need schemas, not raw JSON

Raw JSON wastes tokens and confuses models. A compact schema gives the LLM the structure it needs in a fraction of the size.