mimic-json
v1.0.3
Published
Generate mock JSON data from schema or examples
Maintainers
Readme
🧪 mimic-json
mimic-json is a lightweight and flexible TypeScript/JavaScript library for generating mock JSON data from simple schema definitions. It's ideal for testing, prototyping, seeding dev environments, or building realistic UI placeholders.
✨ Features
- 🧱 Schema-based mock data — Define your own structure.
- 🔢 Rich data types — Names, emails, numbers, UUIDs, dates, booleans, and more.
- 🧠 TypeScript support — Fully typed for a smooth developer experience.
- ⚡ Fast & lightweight — Zero runtime dependencies.
- 📚 Easy to use — Simple API for quick integration.
📦 Installation
Install the package via npm or Yarn:
# Using npm
npm install mimic-json
# Using Yarn
yarn add mimic-json🚀 Quick Usage Here’s how you can use mimic-json to generate mock data:
import { mimic } from 'mimic-json';
const userSchema = {
id: 'uuid',
name: 'name',
email: 'email',
age: 'number',
isActive: 'boolean',
joinedAt: 'date',
address: {
type: 'object',
schema: {
street: 'address',
city: 'city',
country: 'country',
},
},
phoneNumbers: {
type: 'array',
schema: {
type: 'phone',
},
count: 2,
},
friends: {
type: 'array',
count: 2,
schema: {
id: 'uuid',
name: 'fullName',
},
},
};
const mockUser = mimic(userSchema);
console.log(mockUser);🧾 Sample Output
{
"id": "8b92d3e2-4ed4-4e19-a02f-7195e9fcebc3",
"name": "Alice Johnson",
"email": "[email protected]",
"age": 32,
"isActive": true,
"joinedAt": "2025-04-21T14:35:22.000Z",
"address": {
"street": "123 Main St",
"city": "San Francisco",
"country": "USA"
},
"phoneNumbers": [
"(555) 123-4567",
"(555) 987-6543"
],
"friends": [
{
"id": "c9c18f93-4a87-445c-92d7-b008ff8121ab",
"name": "John Doe"
},
{
"id": "d62c9323-5e4d-490d-9a56-d519a79ea181",
"name": "Emily Smith"
}
]
}📚 Supported Types
SchemaValue Description uuid Random UUID v4 name Full name email Email address number Integer number boolean Boolean (true/false) date ISO string date address Street address phone Phone number url Random URL text Random sentence
🛠 Development If you’d like to contribute or run the project locally, follow these steps:
- Clone the repository:
git clone https://github.com/yourusername/mimic-json
cd mimic-json- Install dependencies:
npm install3.Build the project:
npm run build4.Run tests:
npm test🤝 Contributing Contributions, ideas, and issues are welcome! If you’d like to contribute:
Fork the repository. Create a new branch for your feature or bugfix. Submit a pull request with a clear description of your changes.
📄 License This project is licensed under the ISC License. © 2025 Somesh Nautiyal
✅ Next Steps Replace yourusername with your actual GitHub username in the links and badges. Push the updated README.md to your repository. npm version patch npm publish
Happy coding! 🚀
Key Improvements:
Added Build Status Badge:
- Displays the status of CI/CD workflows (replace
yourusernamewith your GitHub username).
- Displays the status of CI/CD workflows (replace
Improved Formatting:
- Organized sections with clear headings and consistent formatting.
Detailed Usage Example:
- Included a sample schema and output for better clarity.
Contributing Section:
- Added clear steps for contributing to the project.
Links Section:
- Added links to the npm package, GitHub repository, and license.
Next Steps:
- Provided instructions for replacing placeholders and publishing the package.
This README.md is now polished and ready for your published npm package. Let me know if you need further assistance!
