OpenAPI Mock Data Generator
Generate realistic JSON mock payloads from OpenAPI schemas with reproducible seeded output
Enter an OpenAPI 3.x or Swagger 2.0 specification in JSON or YAML format
Same seed produces identical output for reproducible results
What is the OpenAPI Mock Data Generator?
The OpenAPI Mock Data Generator parses your OpenAPI 3.x or Swagger 2.0 specification and produces realistic JSON payloads for every endpoint. It reads your schemas — including string formats, enums, nested objects, and arrays — and generates data you can use immediately for testing, prototyping, or documentation. All processing happens in your browser — your API specification never leaves your device.
How to Use
- Paste your OpenAPI or Swagger specification in JSON or YAML format
- Optionally set a seed number for reproducible output
- Click "Generate Mock Data" or wait for automatic processing
- Review generated request and response payloads per endpoint
- Copy results to use in tests, documentation, or API consumers
Example: Generating Mock Responses
Given this schema definition in your OpenAPI spec:
components:
schemas:
User:
type: object
properties:
id:
type: integer
name:
type: string
email:
type: string
format: email
createdAt:
type: string
format: date-time The generator produces realistic mock data like:
{
"id": 472,
"name": "A sample description",
"email": "alice@example.com",
"createdAt": "2024-01-15T10:30:00Z"
} Email fields get realistic addresses, date-time fields get ISO timestamps, and integers respect any min/max constraints defined in the schema.
Reproducible Output with Seeds
The seed option controls the random number generator. Using the same seed with the same specification always produces identical mock data. This is useful for:
- Writing deterministic integration tests that depend on specific values
- Generating consistent documentation examples across builds
- Comparing output before and after schema changes
- Sharing reproducible test scenarios with teammates
Supported Schema Features
- Primitive types — string, number, integer, boolean, null
- String formats — email, uuid, date, date-time, uri, ipv4, ipv6, hostname, password
- Enums — picks a random valid value from the enum list
- Arrays — generates items respecting minItems/maxItems constraints
- Nested objects — recursively generates properties up to 10 levels deep
- $ref references — resolves both #/components/schemas/ and #/definitions/
- Composition — supports allOf (merge), oneOf/anyOf (pick first)
- Constraints — honors minimum, maximum, minLength, maxLength
- Examples and defaults — uses schema example or default values when provided
Use Cases
- API testing — Generate request payloads to feed into Postman, curl, or test suites
- Frontend prototyping — Create mock responses for UI development before the backend is ready
- Documentation — Produce example payloads for API documentation
- Contract testing — Validate that consumers handle all response shapes correctly
- Data seeding — Generate initial data for development databases
Supported Formats
Both JSON and YAML input formats are supported. The tool accepts OpenAPI 3.x and
Swagger 2.0 specifications. Swagger 2.0 specs using the definitions keyword
are handled the same as OpenAPI 3.x components/schemas.
Privacy and Security
All mock data generation happens entirely in your browser using JavaScript. Your API specifications — which may contain internal endpoints, authentication details, and business logic — never leave your device. No data is stored, logged, or transmitted.
Frequently Asked Questions
What does the OpenAPI Mock Data Generator do?
It parses your OpenAPI 3.x or Swagger 2.0 specification and generates realistic JSON payloads for each endpoint. This includes request bodies and response schemas, supporting all common types: strings, numbers, booleans, arrays, enums, and nested objects.
What OpenAPI formats are supported?
Both JSON and YAML formats are supported. The tool accepts OpenAPI 3.x and Swagger 2.0 specifications. It parses $ref references, allOf/oneOf/anyOf compositions, and generates data from component schemas and definitions.
What is the seed option and why would I use it?
The seed is a number that controls the random data generation. Using the same seed with the same specification always produces identical mock data. This is useful for reproducible testing, consistent documentation examples, or comparing outputs across different runs.
How realistic is the generated data?
The generator produces context-aware data based on schema formats. For example, fields with format 'email' get realistic email addresses, 'uuid' fields get proper UUIDs, 'date-time' fields get ISO timestamps, and 'uri' fields get valid URLs. Enums are respected, and min/max constraints are honored.
Is my API specification sent to any server?
No. All parsing and mock data generation happens entirely in your browser using JavaScript. Your OpenAPI specification — which may contain internal endpoints, authentication details, and business logic — never leaves your device.
How does it handle $ref references?
The tool resolves $ref references from both #/components/schemas/ (OpenAPI 3.x) and #/definitions/ (Swagger 2.0). Referenced schemas are resolved recursively, with a depth limit to prevent infinite recursion in circular references.
What happens with circular schema references?
The generator has a maximum depth limit of 10 levels. If a circular reference is detected (a schema referencing itself directly or indirectly), the generator stops at the depth limit and returns null for that nested level, preventing infinite loops.
How is this different from the OpenAPI Viewer?
The OpenAPI Viewer displays and navigates a specification showing endpoints, parameters, and schemas. The Mock Data Generator creates actual JSON payloads you can use for testing API consumers, generating documentation examples, or prototyping frontend integrations.