A modern, intuitive tool to transform JSON data into usable code artifacts for your development workflow. Instantly generate TypeScript interfaces, Zod schemas, and MSW handlers from any JSON structure.
- πͺ AI-Powered JSON Generation: Instantly create complex mock data structures using natural language prompts via the floating AI command bar.
- π Secure Gemini Integration: Securely store your Google Gemini API key in local storage to unlock advanced generative capabilities.
- β‘ Instant Code Generation: Convert JSON to TypeScript interfaces, Zod schemas, and MSW handlers in real-time.
- π³ Visual Tree View: Explore your JSON structure with a clean, interactive tree representation.
- π² Smart Data Randomization: Generate mock data variations while preserving the original JSON structure.
- π οΈ Developer First DX:
- Powered by Monaco Editor (the core of VS Code).
- One-click copy and file downloads.
- Built-in JSON formatting and validation.
- π Glassmorphism UI: A beautiful, modern interface with smooth animations and responsive design.
Simply enter your Gemini API key in the configuration modal to enable the AI features. Your key is only used to communicate with the Google Generative AI API and never leaves your browser.
- React 19 - Modern UI components and hooks.
- TypeScript - Type-safe development.
- Vite 8 - Lightning-fast build and dev server.
- Tailwind CSS 4 - Modern styling.
- Monaco Editor - Robust code editing experience.
- Lucide React - Beautifully simple icons.
- Vitest - Unit testing for core logic.
- Node.js (v18 or higher)
- npm or yarn
-
Clone the repository:
git clone https://github.com/ItkalNagaratna/api-mock.git cd api-mock -
Install dependencies:
npm install
-
Start the development server:
npm run dev
To ensure everything is working correctly, run the unit tests:
npm testIf you want to use the generation engine in your own projects without the full UI, you can easily copy the core utilities:
- Copy Utils: Grab the
src/utils/directory. It containstypeGenerator.tsandmockGenerator.ts. - Usage Example:
import { generateTypeScript } from './utils/typeGenerator'; const json = { id: 1, name: "Test" }; const tsCode = generateTypeScript(json, "MyResponse"); console.log(tsCode);
Note: If you'd like to see this as a standalone NPM package, feel free to open an issue!
- Input: Paste your JSON response into the left panel.
- Review: Use the middle panel to visually inspect the data structure.
- Customize: Click the settings icon in the bottom right to adjust the generated names.
- Export: Copy the generated code from the right panel or download it as a
.tsfile. - Randomize: Use the "Randomize" button in the header to generate mock data for testing edge cases.
We take DX seriously. Recent improvements include:
- Unit Testing: Core logic is covered by Vitest to prevent regressions.
- Modular Utilities: Decoupled generators for better maintainability.
- Enhanced Monaco Integration: Improved JSON validation and formatting.
- Automated Downloads: Easily export artifacts directly to your project.
Distributed under the MIT License. See LICENSE for more information.
Crafted with β€οΈ for developers who hate manual type definitions.
