datafake-rs
A high-performance mock JSON data generation library for Rust.
Uses JSONLogic for flexible and powerful fake data generation.
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
- Define a Configuration - Create a JSON configuration with metadata, variables, and schema
- Use the
fakeOperator - Specify which fake data types to generate using the{"fake": ["type"]}syntax - 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
- Try the Playground to experiment with configurations
- Read Quick Start for usage examples
- Browse Fake Data Types to see all available generators