# JSON Schema Sample Generator

- Human page: https://happytails.ai/en/data-tools/json-schema-sample-generator/
- Markdown: https://happytails.ai/en/data-tools/json-schema-sample-generator.md
- Structured JSON: https://happytails.ai/agents/en/data-tools/json-schema-sample-generator/index.json
- Visibility: public

## Tool capabilities

| Property | Value |
| --- | --- |
| Tool ID | `json-schema-sample-generator` |
| Category | data-tools |
| Implementation | Registered implementation. Registration alone is not a production-quality guarantee. |
| Browser execution | Use the visible action or interactive controls. |
| Browser processing | Browser; see tool notes for network behavior. |
| HTTP API | Not callable through HTTP. |
| Browser-agent interface | run_current_tool |

### Implementation notes

Runs in your browser in a background worker. Accepts a schema of up to 50000 characters and returns only samples that the Ajv validator has checked.

### Inputs and settings

Text input: JSON Schema.

Example or placeholder shown in the interface (not a validated fixture):

```text
{"type":"object","required":["id"],"properties":{"id":{"type":"integer"}}}
```

Paste one schema as JSON or YAML. Local $ref links are followed. Up to 50,000 characters. Review the settings before running.

| Setting | Meaning | Control type | Default | Constraints |
| --- | --- | --- | --- | --- |
| `seed` | Seed | text | "1" |  |
| `validCount` | Valid samples | text | "3" |  |
| `invalidCount` | Invalid samples | text | "3" |  |
| `draft` | JSON Schema draft | select | "auto" | Allowed: auto, draft-07, 2019-09, 2020-12 |

### Browser-agent workflow

1. Open the human page in a browser that supports WebMCP.
2. Discover the interface exposed by that page; use its actual schema.
3. Select files on the page first when the tool requires files.
4. Call `run_current_tool` with valid input and settings.
5. Inspect the returned result or error and the displayed output. Retrieve files from the displayed download links.

Calls do not automatically copy or download results. Browser permissions still apply. Interface availability alone is not proof of successful execution.

### Planning specification

Accepts a schema of up to 50,000 characters, 1 to 100 valid samples and 0 to 100 invalid samples, with a 4,000,000 character result. Everything runs in your browser. Downloads are a JSON report and JSON Lines files.

This describes intended requirements. Use the implementation notes, interface schema and observed output to determine current support.

### Complete machine-readable capability record

```json
{
  "id": "json-schema-sample-generator",
  "category": "data-tools",
  "built": true,
  "requirements": "Accepts a schema of up to 50,000 characters, 1 to 100 valid samples and 0 to 100 invalid samples, with a 4,000,000 character result. Everything runs in your browser. Downloads are a JSON report and JSON Lines files.",
  "implementation": {
    "fields": [
      {
        "key": "seed",
        "label": "Seed",
        "value": "1",
        "type": "text",
        "inputMode": "numeric",
        "maxLength": 10,
        "help": "Whole number from 0 to 4294967295. The same schema, seed and counts always give the same samples."
      },
      {
        "key": "validCount",
        "label": "Valid samples",
        "value": "3",
        "type": "text",
        "inputMode": "numeric",
        "maxLength": 3,
        "help": "Whole number from 1 to 100."
      },
      {
        "key": "invalidCount",
        "label": "Invalid samples",
        "value": "3",
        "type": "text",
        "inputMode": "numeric",
        "maxLength": 3,
        "help": "Whole number from 0 to 100. Each one breaks a single rule of the schema."
      },
      {
        "key": "draft",
        "label": "JSON Schema draft",
        "value": "auto",
        "type": "select",
        "values": [
          "auto",
          "draft-07",
          "2019-09",
          "2020-12"
        ]
      }
    ],
    "registrationFamily": "api-contracts-reference",
    "codeDirection": "ltr",
    "inputMaxLength": 50000,
    "inputErrorCode": "API_CONTRACTS_REFERENCE_TOO_LONG",
    "note": "Runs in your browser in a background worker. Accepts a schema of up to 50000 characters and returns only samples that the Ajv validator has checked.",
    "experience": {
      "automatic": false,
      "single": false,
      "inputMaxLength": 50000,
      "inputMode": "text",
      "label": "JSON Schema",
      "placeholder": "{\"type\":\"object\",\"required\":[\"id\"],\"properties\":{\"id\":{\"type\":\"integer\"}}}",
      "help": "Paste one schema as JSON or YAML. Local $ref links are followed. Up to 50,000 characters. Review the settings before running.",
      "helpParts": [
        "Paste one schema as JSON or YAML. Local $ref links are followed.",
        "Up to 50,000 characters.",
        "Review the settings before running."
      ],
      "action": null
    },
    "mode": "explicit",
    "interactive": false
  },
  "execution": "Browser interface",
  "api": null,
  "browser_agent": {
    "supported": true,
    "name": "run_current_tool",
    "discovery": "WebMCP on the human page in a supporting browser",
    "verification": "See audit/API-AUDIT.md; availability is not verification"
  }
}
```

## Page guide

Create reproducible valid and invalid test data from a JSON Schema. Every sample is checked with a JSON Schema validator before it is offered.

### How to use JSON Schema Sample Generator

1. Paste a JSON Schema as JSON or YAML.
2. Choose a seed and how many valid and invalid samples you want.
3. Run the generator and review which rule each invalid sample breaks.
4. Download the report or the JSON Lines files.

How can we improve this tool?

Report a problem or share an idea.

Please leave out private information. Your message and the tool name go to our team via PostHog.

## Useful next steps

- [JSON schema validator](https://happytails.ai/en/developer-tools/json-schema-validator/) ([Markdown](https://happytails.ai/en/developer-tools/json-schema-validator.md))

- [JSON to schema](https://happytails.ai/en/developer-tools/json-to-schema/) ([Markdown](https://happytails.ai/en/developer-tools/json-to-schema.md))

- [Schema generator](https://happytails.ai/en/web-tools/schema-generator/) ([Markdown](https://happytails.ai/en/web-tools/schema-generator.md))

Accepts a schema of up to 50,000 characters, 1 to 100 valid samples and 0 to 100 invalid samples, with a 4,000,000 character result. Everything runs in your browser. Downloads are a JSON report and JSON Lines files.

## How samples are made

The generator walks the schema and picks values from types, enums, ranges, lengths, simple patterns and common formats with a seeded random number generator, so the same seed gives the same samples. Each candidate is then validated with Ajv. A candidate that fails is replaced, and after 25 tries the sample is listed as one that could not be generated instead of being emitted.

### Invalid samples

Invalid samples start from a valid one and break one rule at a time, such as a wrong type, a missing required property, a value outside an enum or range, or an extra property. Each is validated again and the report names the keyword that failed.

### Limits

Only local references inside the schema are followed; references to other files or URLs are never fetched. Complex regular expressions, not and some combinations of oneOf can exceed the generator's supported search. Those samples are reported as not generated. Schemas using \_\_proto\_\_ as a property, pattern or dependency key are rejected because the bundled validator cannot check that key reliably. Literal instance data with that key is preserved.
