Schema Converter
JSON to TypeScript & Zod Online
Transform JSON instantly into TypeScript interfaces, Zod schemas, JSON Schema, or GraphQL types. Features recursive type inference and professional customization options.
JSON Input
Generated Schema
Join Amazon and Flipkart Deals and products under 99 Telegram Channel: @atjust99
What This Tool Does
You have a JSON object from an API response. You need TypeScript types, or Zod validation, or a JSON Schema draft, or GraphQL type definitions. This tool infers the structure recursively and outputs the corresponding code.
Paste JSON on the left, pick an output format, and copy the result. It handles nested objects, arrays of objects, mixed types, and null values. Everything runs in your browser.
Supported Output Formats
TypeScript
Generates interface declarations by default. Each nested object gets its own named interface. Array items are typed based on the first element. You can toggle between interface and type in the settings.
Example input:
{
"user": { "id": 1, "name": "Alice" },
"tags": ["admin", "active"]
}Output:
interface User {
id: number;
name: string;
}
interface RootObject {
user: User;
tags: string[];
}Zod
Generates z.object() schemas compatible with Zod v3. Nested objects produce separate schema variables. This is useful when you want runtime validation that stays in sync with your types — Zod can infer TypeScript types from schemas via z.infer<>.
JSON Schema
Outputs Draft-07 compliant schemas with type, properties, and required fields. Useful for OpenAPI documentation or form validation libraries that consume JSON Schema (like Ajv).
GraphQL
Produces type definitions. Nested objects become separate named types. Arrays are typed as [TypeName]. This gives you a starting point for your schema definition — you'll still need to wire up resolvers.
JSDoc
Generates @typedef blocks for plain JavaScript projects that don't use TypeScript but still want IDE autocompletion via JSDoc annotations.
How Type Inference Works
The converter walks your JSON depth-first. For each value it encounters:
- Strings →
string/z.string()/String(GraphQL) - Numbers →
number/z.number()/Float(GraphQL usesFloatsince JSON doesn't distinguish int vs float) - Booleans →
boolean/z.boolean()/Boolean - Null →
null/z.null()— notany, since the tool explicitly handles null values - Objects → a new named interface/schema, with the key converted to PascalCase (e.g.,
shipping_address→ShippingAddress) - Arrays → typed by inspecting the first element. Empty arrays become
any[]since there's no data to infer from
Name collisions: If two different nested objects produce the same PascalCase name, the second gets a numeric suffix (User, User2). This can happen with keys like user at different nesting depths.
A note on inference limits: This tool works from a single JSON sample. It can't know that a field is sometimes absent, sometimes a different type, or constrained to specific values. For those cases, edit the generated output to add optional markers (?), union types, or enums. The "Make All Optional" toggle helps when you're modeling partial/patch payloads.
Practical Use Cases
Typing an API response: Hit an endpoint with curl or your browser's network tab, copy the JSON, paste it here, and get TypeScript interfaces you can immediately use in your frontend.
Bootstrapping Zod validation: Rather than hand-writing validation for a 20-field object, generate the base schema and then add refinements (.min(), .email(), .regex()) to the fields that need them.
Documenting an internal API: Generate JSON Schema from a sample response and use it in your OpenAPI spec. This is faster than writing the schema by hand, even if you need to add descriptions and examples afterward.
Starting a GraphQL schema: If you have REST endpoints and want to wrap them in GraphQL, converting sample responses gives you type definitions to start from.
Frequently Asked Questions
How does it handle null values?
null is typed as null in TypeScript and z.null() in Zod. Previous versions inferred any for null, but the current version handles it explicitly.
Can it infer union types from arrays with mixed types?
Not automatically. If an array contains both strings and numbers, it types the array based on the first element. You'll need to edit the output to add (string | number)[] manually.
Does it preserve my original key names? Yes. Interface properties use the exact keys from your JSON. Only interface/type names are converted to PascalCase.
Is my data stored anywhere? No. All processing happens in the browser. Nothing is sent to a server.
What Zod version does the output target?
Zod v3.x. The generated schemas use z.object(), z.string(), z.number(), z.boolean(), z.null(), and z.array().
Can I use type instead of interface for TypeScript?
Yes. There's a toggle in the settings panel.
How do I handle optional fields?
Use the "Make All Optional" toggle to add ? to TypeScript properties and .optional() to Zod fields. For selective optionality, edit the generated output directly.
Related Tools
- API Response Mocker - Create mock data to test your schemas against
- JSON Prettifier - Format JSON before converting
- HTTP Header Analyzer - Audit the endpoints serving your data
- Code Screenshot Generator - Share your generated types visually
Related Tools
AI Acronym Finder: Instantly Decode Any Abbreviation
Developer ToolsStruggling with industry jargon? Our AI-powered Acronym Finder provides instant, context-aware definitions for any acronym or initialism. Get clear explanations and usage examples in seconds.
Code Screenshot Generator - Beautiful Code Snippet Images
Developer ToolsTransform your source code into stunning, professional screenshots. Choose from multiple editor themes, vibrant gradients, and macOS-style frames. Perfect for Twitter, LinkedIn, and blogs.
Color Palette Generator - Extract Colors From Image & Hex
Developer ToolsCreate professional color schemes in seconds. Extract palettes from images or generate them from hex codes with instant export to CSS, Tailwind, and Figma.
Cron Expression Builder - Visual Cron Schedule Generator
Developer ToolsCreate and test cron expressions visually. Generate human-readable schedules, preview upcoming run times, and use presets for Linux crontab and automation workflows.
HTML to Markdown Converter
Developer ToolsEffortlessly convert your HTML code into clean, readable Markdown with our free online tool. Perfect for developers, writers, and content managers.
HTTP Header Analyzer - Professional Website Security Audit
Developer ToolsScan your website headers for security vulnerabilities, caching efficiency, and information leakage. Get a professional grade (A+ to F) and actionable advice to harden your server.
Markdown Table Generator - Professional Online Table Editor
Developer ToolsCreate clean, aligned Markdown tables visually. Features spreadsheet-like editing, CSV/JSON imports, and instant export to Markdown, HTML, and CSV for GitHub and documentation.
Test MCP Server Online - Free Model Context Protocol Debugger
Developer ToolsExplore, test, and debug Model Context Protocol (MCP) servers with our advanced GUI. Discover available tools, execute methods with custom JSON arguments, and monitor real-time logs.
Random CSV Generator - Generate Structured CSV Data
Developer ToolsGenerate random CSV data with custom columns, data types, and export options. Create test data, sample datasets, and structured information for analysis and development.
Random TSV Generator - Generate Tab-Separated Values
Developer ToolsGenerate random TSV data with custom columns and data types. Create structured tab-separated files perfect for data analysis, spreadsheet applications, and simple data exchange.
Regex Playground - Live Regular Expression Tester & Debugger
Developer ToolsBuild, test, and debug regular expressions in real-time. Features live match highlighting, capture group visualization, and a comprehensive pattern library for JavaScript, Python, and more.
SVG Editor & Optimizer - Professional Online Vector Tool
Developer ToolsEdit, clean, and optimize SVG files in real-time. Reduce file size, remove metadata, and preview vector changes instantly for faster web performance.