Loading JSON to Schema Converter...
Please wait a moment

How to Generate JSON Schema - Step by Step Guide

Step 1

Input Your JSON Data

Let's get your JSON data ready for schema generation! You have several convenient options:

•
Paste directly: Copy your API response or JSON data and paste it into the input editor
•
Upload a file: Click "Upload" to select a .json or .txt file from your computer
•
Try the sample: Click "Sample" to load example data and see how the schema generator works

Example: Sample JSON Input

Here's what sample JSON data looks like:

{
  "planId": "TEL-UNLIMITED-5G",
  "planName": "Unlimited 5G Premium",
  "provider": "TelecomCorp",
  "pricing": {
    "basePrice": 89.99,
    "currency": "USD",
    "billingCycle": "monthly"
  },
  "features": [
    "unlimited_data",
    "5g_access",
    "international_roaming"
  ],
  "isActive": true
}
Step 2

Configure Schema Options

Customize your schema generation! Choose the JSON Schema version and additional options:

•
Schema Version: Choose from Draft 2020-12 (latest), 2019-09, 07, or 06
•
Include Examples: Add your original JSON as example data in the schema
•
Include Descriptions: Add helpful titles and descriptions to make schemas self-documenting

Example: Schema Configuration Options

The tool automatically analyzes your JSON and applies these settings:

✓Draft 2020-12 selected (latest standard)
✓Examples included for validation testing
✓Descriptions added for better documentation
Step 3

Automatic Schema Generation

Watch the magic happen! The tool instantly analyzes your JSON and generates a complete JSON Schema with validation rules:

•
Type inference: Automatically detects string, number, boolean, object, array, and null types
•
Required fields: Marks a property as required when it has a value; for a list of records, only when every record has it
•
Nested validation: Creates sub-schemas for nested objects and arrays

Example: Generated JSON Schema Output

Your input JSON becomes this comprehensive schema:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "title": "Generated Schema",
  "properties": {
    "planId": {
      "type": "string"
    },
    "pricing": {
      "type": "object",
      "properties": {
        "basePrice": { "type": "number" }
      }
    },
    "features": {
      "type": "array",
      "items": { "type": "string" }
    }
  },
  "required": ["planId", "pricing", "features"]
}
Step 4

Export Your Schema

Get your schema ready for use! Multiple export options make it easy to integrate into your workflow:

•
Copy to clipboard: One-click copying for quick pasting into your code editor or application
•
Download as file: Save as a .json schema file for use in validation libraries
•
Generated badge: The green label means the schema matches what is in the editor right now. If your JSON has a mistake, you get the line and column of the problem instead

What is JSON Schema?

JSON Schema is a vocabulary that allows you to annotate and validate JSON documents. It provides a contract for JSON data, describing the structure, data types, and validation rules that JSON data should follow.

Think of JSON Schema as a blueprint that defines what valid JSON should look like, ensuring data consistency and enabling automatic validation across different systems and applications.

Frequently Asked Questions

What is the difference between JSON and JSON Schema?

JSON is the data itself, the thing your API sends or your config file holds. JSON Schema is a separate JSON document that describes what that data is allowed to look like: which properties exist, what type each one has and which ones must be there. Validators read the schema and tell you whether a given JSON document fits it.

Which JSON Schema version should I use?

For new projects, use Draft 2020-12 as it's the latest stable version with the most features. However, if you're working with existing systems, Draft 07 is widely supported. Check your validation library's compatibility first.

Can I validate JSON data against the generated schema?

Yes. The schema works with any standard validator, such as Ajv in JavaScript or jsonschema in Python, and it is built so that the example you pasted passes it. Other documents may still fail if they contain fields or types your example never showed, so test it against a few more real samples.

How does the tool decide which fields are required?

A property is listed under "required" when it has a non-null value in your example. A property that is null gets type "null" and is left out of "required". For an array of objects, every item is looked at: a field is only required if every item has it with a value, and fields that appear in just some items are still listed under "properties".

How does the tool handle nested objects and arrays?

Every nested object gets its own "properties" block, written inline where it appears (the tool does not split them into $defs or $ref). Arrays get an "items" schema built from all of their items, not just the first one, so a list of records with slightly different keys still produces one schema that all of them pass.

What happens with arrays containing different data types?

The "items" schema becomes an "anyOf" with one entry per type found, for example string, integer and object, and each type is listed once no matter how many items share it. If an array mixes whole numbers and decimals, the tool uses plain "number", which accepts both.

Are my numbers kept exactly in the examples?

Yes. With Include Examples turned on, your JSON is copied into "examples" with every number written the way you typed it, so a long ID like 8901240544102066246 keeps all its digits and 14.50 stays 14.50. Long IDs are typed as "integer", not "string".

Is the JSON Schema generator free?

Yes, it's free and there's nothing to sign up for. The schema is generated in your browser, so your JSON isn't uploaded anywhere. The only real limit on input size is your device's memory; a few megabytes of JSON works fine.