# JSON Schema Generator API

> JSON Schema Generator is a JSON to JSON Schema API: it inspects sample JSON payloads and generates Draft-07 JSON Schema definitions with inferred types and property formats. It identifies formats like emails and dates, applies custom titles, and lists all properties as required.

**Endpoint:** `POST https://api.apiverve.com/v1/jsonschemagenerator`  
**Category:** Data Generation  
**Cost:** 2 credits per call  
**Canonical page:** https://apiverve.com/marketplace/jsonschemagenerator

## Overview

Use it to create a JSON schema from an example payload in one call, then hand the result to your documentation, validation or code generators. JSON Schema Generator works by analyzing the structure and data types in sample JSON to produce a valid JSON Schema. It detects formats like date, email, and URI automatically and marks all fields as required.

## Authentication

Every call carries your key in an `x-api-key` header. The same key works across the whole
APIVerve catalog — there are no per-API subscriptions. Responses always use the same three
top-level keys: `status`, `error`, and `data`.

## Example request

```bash
curl -X POST "https://api.apiverve.com/v1/jsonschemagenerator" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"json":{"name":"John Doe","age":30,"email":"john@example.com","active":true},"title":"User Schema","description":"value"}'
```

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `json` | object | Yes | The sample JSON data to generate a schema from |
| `title` | string | No | The title for the generated schema (default: 'Generated Schema'). default Generated Schema |
| `description` | string | No | Optional description for the schema |

## Response fields

- `$schema` — string · JSON Schema version URI (e.g., Draft-07)
- `title` — string · Title of the generated schema definition
- `type` — string · Root schema type (e.g., object, array)
- `properties` — object · Field definitions with inferred types and formats
  - `properties.name` — object
    - `properties.name.type` — string · Root schema type (e.g., object, array)
  - `properties.age` — object
    - `properties.age.type` — string · Root schema type (e.g., object, array)
  - `properties.email` — object
    - `properties.email.type` — string · Root schema type (e.g., object, array)
    - `properties.email.format` — string
  - `properties.active` — object
    - `properties.active.type` — string · Root schema type (e.g., object, array)
- `required` — array · Array of field names marked as required

## Sample response

```json
{
  "status": "ok",
  "error": null,
  "data": {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "User Schema",
    "type": "object",
    "properties": {
      "name": {
        "type": "string"
      },
      "age": {
        "type": "integer"
      },
      "email": {
        "type": "string",
        "format": "email"
      },
      "active": {
        "type": "boolean"
      }
    },
    "required": [
      "name",
      "age",
      "email",
      "active"
    ]
  }
}
```

## Use cases

- **API Documentation** — Generate JSON schemas for API request/response documentation automatically from sample data
- **Data Validation** — Create validation schemas for JSON data in applications, APIs, or configuration files
- **Contract Testing** — Generate schemas from API responses to use in contract testing and API monitoring
- **Code Generation** — Use generated schemas as input for code generation tools to create type-safe data models

## SDKs

- **npm** — `npm install @apiverve/jsonschemagenerator` (https://www.npmjs.com/package/@apiverve/jsonschemagenerator)
- **NuGet** — `dotnet add package APIVerve.API.JSONSchemaGenerator` (https://www.nuget.org/packages/APIVerve.API.JSONSchemaGenerator)
- **Source** — https://github.com/apiverve/jsonschemagenerator-api

## More

- Full reference: https://docs.apiverve.com/ref/jsonschemagenerator
- Get an API key: https://dashboard.apiverve.com
- Full catalog: https://apiverve.com/marketplace
