Registry / testing / json-schema-faker-bb

json-schema-faker-bb

JSON →
library0.5.0-rc12jsnpmunverified

JSON Schema Faker (jsf) uses JSON Schema alongside fake data generators (Faker.js, Chance.js, Casual) to produce consistent and meaningful fake data. The current stable series is v0.5.x release candidate (rc12), with full async support via jsf.resolve() for handling local/remote $ref references. It supports JSON Schema draft-04 and provides a sync API via jsf() for simpler use cases. Key differentiators: built-in integration with multiple fake data providers, custom format support, and a rich set of options for controlling randomness.

npm install json-schema-faker-bb
INSTALL
IMPORT
SIG · JSON-SCHEMA-FAKER-
J
json-schema-faker-bb
testingjavascriptv0.5.0-rc12
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (jsf)
import jsf from 'json-schema-faker';
const jsf = require('json-schema-faker');
Since v0.5.x, the recommended import is ESM. The older CJS require still works but may cause issues with async methods. Use 'jsf' as the default import.
jsf.resolve
import jsf from 'json-schema-faker'; jsf.resolve(schema).then(result => ...);
jsf = require('json-schema-faker'); jsf.sync(...);
jsf.sync() was removed in v0.5.0-rc3. Use jsf.resolve() for async results. For backward compatibility, jsf() remains sync.
types
import type { JSFOptions } from 'json-schema-faker';
import { JSFOptions } from 'json-schema-faker'; (if using JSFOptions at runtime)
TypeScript types are available in the package. Import types using the 'type' modifier to avoid runtime issues.

Shows both async (jsf.resolve) and sync (jsf) generation of fake data from a JSON Schema with faker and format providers.

import jsf from 'json-schema-faker'; const schema = { type: 'object', properties: { name: { type: 'string', faker: 'name.findName' }, age: { type: 'integer', minimum: 18, maximum: 99 }, email: { type: 'string', format: 'email' } }, required: ['name', 'age', 'email'] }; // Async (recommended for handling $ref) jsf.resolve(schema).then(result => { console.log(result); // e.g., { name: 'John Doe', age: 42, email: 'john@example.com' } }).catch(err => console.error(err)); // Sync (no $ref support) const result = jsf(schema); console.log(result);
Debug
Known issues
breakingjsf.sync() was removed in v0.5.0-rc3. Use jsf.resolve() for async results.
fix
Replace jsf.sync(schema) with jsf.resolve(schema).then(...).
affects: >=0.5.0-rc3
breakingAll code examples from v0.4.x and below are not compatible with v0.5.x RC.
fix
Update to async API (jsf.resolve) and check option names.
affects: >=0.5.0-rc1
deprecatedUsing CommonJS require may cause issues with async methods. ESM imports are recommended.
fix
Use import jsf from 'json-schema-faker' instead of const jsf = require('json-schema-faker').
affects: <0.6.0
gotchajsf() sync method does not support $ref resolution, only jsf.resolve does.
fix
Use jsf.resolve() when your schema contains $ref pointers.
affects: >=0.5.0
gotchaThe package json-schema-faker-bb is a fork and may have different behavior. Ensure you are using the correct package.
fix
Check the package name and use 'json-schema-faker' if possible.
affects: *
Errors
Common errors & fixes
TypeError: jsf.sync is not a function
jsf.sync was removed in v0.5.0-rc3.
fix
Use jsf.resolve() instead: jsf.resolve(schema).then(result => ...)
Cannot resolve remote $ref: Error downloading https://...
Missing json-schema-ref-parser dependency or network issue.
fix
Install json-schema-ref-parser: npm install json-schema-ref-parser --save
ReferenceError: jsf is not defined
Incorrect import or module system mismatch.
fix
Use import jsf from 'json-schema-faker' (ESM) or const jsf = require('json-schema-faker') (CJS). Ensure the package is installed.
Upgrade
Version history
0.5.0-rc12latest on npm
Audit
Dependencies
json-schema-ref-parseroptionalUsed for resolving remote $ref references in async mode
Agent activity
10 hits · last 30 days
node
8
Amazon
1
Resources
json-schema-faker-bb — npm install json-schema-faker-bb · libregistry