Skip to content
← Blog
HomeBlogJSON Schema Generator Tutorial

How to Generate JSON Schema from JSON: Step-by-Step Tutorial

By Bill Crawford Β· March 2, 2026 Β· 5 min read  Β·  Last updated March 02, 2026

This tutorial walks through generating a JSON Schema from real-world JSON data using the JSON Schema Generator. You will paste sample JSON, configure the inference settings, review the generated schema, and export to TypeScript and Zod.

πŸ”§ Open the tool to follow along:

Open JSON Schema Generator

Table of Contents

  1. 1 Prepare Your JSON
  2. 2 Paste or Load the JSON
  3. 3 Configure Inference Settings
  4. 4 Review the Generated Schema
  5. 5 Export to TypeScript, Zod, C#, or SQL
  6. 6 Handle Warnings and Edge Cases
  7. Common Pitfalls
  8. Related Tools & Guides

1 Prepare Your JSON

Start with a representative JSON sample. The more complete the sample, the more accurate the inferred schema will be. For this tutorial, we will use a JSON array of user objects β€” a common API response shape:

[
  {
    "id": 1,
    "name": "Alice Johnson",
    "email": "[email protected]",
    "role": "admin",
    "active": true,
    "created": "2025-01-15T09:30:00Z",
    "tags": ["engineering", "leadership"]
  },
  {
    "id": 2,
    "name": "Bob Smith",
    "email": null,
    "role": "viewer",
    "active": false,
    "created": "2025-06-22T14:00:00Z"
  }
]

Notice that the second object is missing the tags field and has email: null. These are the kinds of inconsistencies the generator handles automatically.

2 Paste or Load the JSON

Open the JSON Schema Generator and paste the JSON into the input area on the left. You can also drag-and-drop a .json file onto the drop zone, or click "browse" to pick a file from your disk.

As soon as valid JSON is detected, the validation indicator will show βœ… Valid JSON and the schema will begin generating automatically.

πŸ’‘ Tip: Use the "Example JSON…" dropdown to load one of the built-in samples if you want to explore the tool before using your own data.

3 Configure Inference Settings

The options bar at the top controls how the schema is inferred. For our tutorial JSON, set:

The schema regenerates instantly whenever you change a setting.

4 Review the Generated Schema

The JSON Schema tab on the right shows the full schema. For our sample, you should see something like:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "id": { "type": "integer" },
      "name": { "type": "string" },
      "email": { "type": ["string", "null"], "format": "email" },
      "role": { "type": "string" },
      "active": { "type": "boolean" },
      "created": { "type": "string", "format": "date-time" },
      "tags": { "type": "array", "items": { "type": "string" } }
    },
    "required": ["active", "created", "id", "name", "role"]
  }
}

Key observations:

5 Export to TypeScript, Zod, C#, or SQL

Click the TypeScript tab to see the generated type definition:

type Root = { id: number; name: string; email?: string | null; role: string; active: boolean; created: string; tags?: string[] }[];

Click the Zod tab for a runtime validation schema:

import { z } from "zod";

export const Root = z.array(z.object({
  id: z.number().int(),
  name: z.string(),
  email: z.string().email().nullable().optional(),
  role: z.string(),
  active: z.boolean(),
  created: z.string().datetime(),
  tags: z.array(z.string()).optional(),
}));

The C# tab generates POCO classes and the SQL tab generates a CREATE TABLE statement. Use the Copy or Download buttons to export any output.

6 Handle Warnings and Edge Cases

Check the warnings panel below the tool for any issues the generator detected. Common warnings include:

These warnings help you understand limitations of the inference and decide whether to adjust the schema manually.

Common Pitfalls

πŸ”§ Try it yourself β€” paste any JSON and get a complete schema in seconds.

Open JSON Schema Generator
BC
Bill Crawford
Founder, Data Conversion Center

Bill builds browser-based developer tools that prioritize privacy and speed. With a background in data engineering and API design, he focuses on making common developer tasks faster and more accessible.