Export Seed Data as a JSON Array

Generate seed data in JSON array format for API mocking, test fixtures, or ORM seeding. Learn how SQL types map to JSON types in the output.

Output Formats

Detailed Explanation

JSON Output Format

The JSON Array output format produces a structured array of objects where each object represents a database row. This is ideal for scenarios where raw SQL is not the best fit.

Single Table Output

For a single table, the output is a plain JSON array:

[
  {
    "id": 1,
    "first_name": "James",
    "last_name": "Smith",
    "email": "james.smith42@gmail.com",
    "is_active": true
  },
  {
    "id": 2,
    "first_name": "Emily",
    "last_name": "Garcia",
    "email": "emily.garcia17@outlook.com",
    "is_active": false
  }
]

Multiple Table Output

When the schema contains multiple tables, the output becomes an object keyed by table name:

{
  "users": [ ... ],
  "products": [ ... ]
}

SQL Type → JSON Type Mapping

SQL Type JSON Type Example
INTEGER, SERIAL number 42
DECIMAL, FLOAT number 19.99
VARCHAR, TEXT string "hello"
BOOLEAN boolean true
TIMESTAMP, DATE string "2023-07-15 14:27:38"
NULL values null null

Use Cases for JSON Seeds

  • API Mocking: Load the JSON into a mock server (e.g., MSW, json-server) to simulate backend responses during frontend development
  • Test Fixtures: Import the JSON file in your test suite as a fixture for integration and E2E tests
  • ORM Seeding: Use frameworks like Prisma, Sequelize, or TypeORM that accept JSON objects for their seed scripts
  • Frontend Prototyping: Feed the JSON directly into React state or a context provider for UI development

Pretty-Printed Output

The JSON output is always formatted with 2-space indentation for readability. You can minify it externally if size is a concern.

Use Case

You are building a React frontend with a mock API layer. You need a JSON file of realistic user and product data to load into MSW (Mock Service Worker) so your team can develop and test the UI without waiting for the backend API to be ready.

Try It — Database Seed Generator

Open full tool