JSON Schema Tools

How to work with JSON Schema tools – step-by-step guide

Use JSON Schema to document API contracts, validate JSON payloads, and generate realistic mock data for tests and demos.

  1. Step 1 – Start from a real sample

    • Paste a real API response, request payload, or config JSON into the formatter first.
    • Keep one canonical JSON example per endpoint to avoid schema drift.
  2. Step 2 – Generate a baseline schema

    • Use the Schema Generator to infer types, required fields, and nested structure.
    • Refine descriptions, formats, and constraints (min/max, patterns) for production use.
  3. Step 3 – Validate JSON against the schema

    • Paste your schema and real payloads into the Schema Validator.
    • Fix errors by updating either the JSON sample (bugs) or the schema (contract changes).
  4. Step 4 – Generate mock data for testing

    • Open the Mock Generator to create realistic sample payloads matching your schema.
    • Use seed + batch size to make test data reproducible and scalable.
  5. Step 5 – Share and reuse

    • Save schemas in version control and link them in your API docs.
    • Generate typed code (TypeScript/Java/etc.) from stable JSON samples.

Important note about JSON Schema features

  • Some schemas rely on advanced keywords like $ref, anyOf, oneOf, and allOf.
  • Validators vary in how fully they support drafts and keywords; use a full JSON Schema validator in CI for strict compliance.
Example: JSON → JSON Schema (simplified)
// JSON input
{
  "id": 1,
  "name": "Maeve Winters",
  "active": true,
  "tags": ["developer", "backend"]
}

// Generated schema (example)
{
  "type": "object",
  "properties": {
    "id": { "type": "integer" },
    "name": { "type": "string" },
    "active": { "type": "boolean" },
    "tags": {
      "type": "array",
      "items": { "type": "string" }
    }
  },
  "required": ["id", "name", "active", "tags"]
}

Related JSON Schema & validation tools

Use these tools to generate schemas, validate data, create mock payloads, and turn stable JSON into typed code.

Frequently Asked Questions

What is a JSON Schema?

JSON Schema is a vocabulary that allows you to annotate and validate JSON documents. It provides a contract for what JSON data is required for a given application and how to interact with it.

When should I generate a schema vs validate against one?

Generate a schema when you want to create validation rules from existing JSON data. Use validation when you have an existing schema and want to check if your JSON data conforms to it.

What's the difference between the generator and validator?

The Schema Generator creates a new JSON schema from your data, while the Schema Validator checks if your JSON data follows an existing schema's rules and constraints.

Can I use schemas from other tools?

Yes! Both tools support standard JSON Schema formats (Draft 4, 6, 7, and 2019-09), so you can import schemas from other applications or export them for use elsewhere.

JSON Schema Tools & Generator | JSONSwiss