Skip to content
Back to skills

Json Schema Faker

ASecurity

Generate realistic fake data from JSON schemas, producing 1-50 valid records that conform exactly to the schema. Use when creating sample datasets from schema definitions, populating test databases, or generating example API responses. Returns only valid JSON that passes schema validation.

  • 666 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added February 9, 2026
developmentjavascriptjavabashnodeapidatabase

Works with

  • api

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill json-schema-faker --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Json Schema Faker?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Json Schema Faker
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-json-schema-faker/badge)](https://www.skillsdirectory.com/skills/majiayu000-json-schema-faker)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: json-schema-faker
description: Generate realistic fake data from JSON schemas, producing 1-50 valid records that conform exactly to the schema. Use when creating sample datasets from schema definitions, populating test databases, or generating example API responses. Returns only valid JSON that passes schema validation.
---

# JSON Schema Faker Skill

Generate realistic fake data from JSON schemas with guaranteed validity.

## Quick Start

When you have a JSON schema and need realistic sample data:

```bash
node scripts/generate-fake-data.mjs /path/to/schema.json 25
```

This generates 25 valid records conforming to your schema.

## Requirements

Install dependencies first:

```bash
npm install @json-schema-faker/core ajv
```

## How It Works

1. **Parse schema** - Loads and validates your JSON schema
2. **Configure faker** - Sets up realistic data generation with custom rules
3. **Generate records** - Creates 1-50 records using faker
4. **Validate output** - Validates each record against the schema
5. **Return JSON** - Outputs only valid records as pretty-printed JSON

## Features

**Schema Compliance**: All generated records are validated against the schema—only valid JSON is returned.

**Realistic Data**: Uses faker.js with domain-specific extensions (currency codes, country codes, time windows) to produce realistic data beyond simple random strings.

**Customizable**: Specify 1-50 records. Script auto-caps at 50.

**Error Handling**: Handles generation failures gracefully; reports warnings for records that couldn't be generated after multiple attempts.

## Usage

### Basic Generation

```bash
node scripts/generate-fake-data.mjs schema.json 10
```

Generates 10 records from `schema.json`, outputs JSON to stdout.

### Specify Record Count

```bash
node scripts/generate-fake-data.mjs schema.json 50
```

Records are capped at 50 maximum. If omitted, defaults to 10.

### Save to File

```bash
node scripts/generate-fake-data.mjs schema.json 30 > output.json
```

## Improving Data Quality

The faker library generates realistic data based on schema hints. To improve data quality:

1. **Add format hints**: Use `"format": "email"`, `"format": "date"`, `"format": "uri"`
2. **Add faker directives**: Use `"faker": "name.firstName"` to guide generation
3. **Use enums**: For constrained fields, provide valid options
4. **Set constraints**: Use `minimum`, `maximum`, `minLength`, `maxLength` appropriately
5. **Avoid overly restrictive patterns**: Very complex regex patterns may cause generation to fail

See `references/faker-customization.md` for detailed customization options and available faker methods.

## Example: Accommodation Listings

Given a schema for accommodation listings (with faker hints for currency and country), the skill generates realistic data like:

```json
[
  {
    "id": "listing_ashdod_001",
    "title": "Beachfront Apartment",
    "type": "apartment",
    "location": {
      "city": "Ashdod",
      "countryCode": "IL",
      "distanceToBeachMinutes": 5,
      "coordinates": { "lat": 31.8, "lng": 34.65 }
    },
    "rating": { "score": 8.5, "count": 45 },
    "pricePreview": {
      "currency": "USD",
      "nightly": 180,
      "total": 540,
      "nights": 3
    },
    ...
  }
]
```

## Troubleshooting

**"Could not generate valid record"**: The schema may have constraints that conflict (e.g., minLength > maxLength). Review your schema constraints.

**"Failed to parse schema"**: Ensure the schema file is valid JSON.

**Too few records generated**: Some schemas have tight constraints. Increase attempts or relax schema constraints.

## Advanced Customization

To add custom faker methods beyond the built-in ones (currencyCode, countryCode, timeWindow), edit the `setupFaker()` function in `scripts/generate-fake-data.mjs`.

Example: Add a custom "accommodationType" method:

```javascript
faker.accommodationType = () => {
  const types = ['apartment', 'house', 'hotel', 'bnb']
  return faker.random.arrayElement(types)
}
```

Then use in your schema:

```json
{
  "type": "string",
  "faker": "accommodationType"
}
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.