Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Plasmatic Logo

datafake-rs

A high-performance mock JSON data generation library for Rust.

Uses JSONLogic for flexible and powerful fake data generation.

License Rust Crates.io

OrganizationDocsReport a Bug


datafake-rs is designed for testing, prototyping, and development scenarios where you need realistic mock data.

Features

  • JSONLogic Integration - Use powerful JSONLogic expressions to define your data schema
  • 50+ Fake Data Types - Generate names, addresses, emails, phone numbers, financial data, and more
  • Variables - Pre-generate values and reuse them across your schema
  • Batch Generation - Generate multiple records efficiently
  • WebAssembly Support - Use in browsers and Node.js via WASM

Quick Example

Here’s a simple example that generates a user profile:

How It Works

  1. Define a Configuration - Create a JSON configuration with metadata, variables, and schema
  2. Use the fake Operator - Specify which fake data types to generate using the {"fake": ["type"]} syntax
  3. Generate Data - The library evaluates the schema and produces realistic fake data

Configuration Structure

A datafake configuration has three optional sections:

{
    "metadata": {
        "name": "User Generator",
        "version": "1.0.0"
    },
    "variables": {
        "userId": {"fake": ["uuid"]}
    },
    "schema": {
        "id": {"var": "userId"},
        "name": {"fake": ["name"]},
        "email": {"fake": ["email"]}
    }
}
  • metadata - Optional information about the configuration
  • variables - Pre-generate values that can be referenced in the schema
  • schema - The structure of the output data with fake data operators

Next Steps