json-schema-faker produces valid sample JSON from JSON Schema definitions with zero production dependencies. It offers async and sync APIs, a CLI, and optional faker or chance extensions.
Overview
JSON Schema Faker generates instance data that satisfies a given JSON Schema document. The implementation is written in TypeScript for Bun and Node-like runtimes and advertises no required production dependencies beyond optional integrations you opt into.
It supports JSON Schema drafts 2019-09 and 2020-12, including composition keywords, conditional properties, $ref resolution with cycle handling, remote references via a resolver helper, built-in string formats, regex patterns through an AST-based generator, and custom formats or keywords registered at runtime. Seeded randomness enables deterministic output for tests.
Programmatic entry points include generate, reusable generators, synchronous variants for in-memory schemas, helpers that emit JSON or YAML strings, and hooks to transform output. Optional extensions connect faker.js or chance.js for richer strings, and a yaml extension for YAML serialization.
A global jsf CLI reads schema files or stdin, writes to stdout or files, and exposes flags for counts, seeds, depth limits, and optional property filling. Standalone binaries are published per platform for Linux, macOS, and Windows architectures.
Key features
- JSON Schema 2019-09 and 2020-12 support
- Seeded deterministic generation
- $ref and remote schema resolution
- Custom formats and keyword extensions
- Sync and async generate APIs
- JSON and YAML output helpers
- Optional faker and chance extensions
- jsf command-line tool
Use cases
- Mock API payloads from schemas
- Fixture data for automated tests
- Prototyping forms and UIs
- CLI batch sample generation
- Contract testing with repeatable seeds