JSON to TypeScript
Generate TypeScript interfaces and types from any sample JSON. Handles nested objects, arrays, optional fields, and mixed types. Paste JSON, copy the interface.
How to use the json to typescript
Paste a JSON sample and click Generate. The result is a set of TypeScript interfaces and type aliases that match the structure. Larger or more varied samples produce more accurate unions.
Formula & explanation
We walk the JSON tree once, emit a TypeScript shape for each unique object structure, and wire arrays + unions automatically. Fields that vary between samples become optional.
Examples
{"id":1,"tags":["a","b"]} produces interface Root { id: number; tags: string[]; }
Frequently asked questions
- Can I paste an array?
- Yes — top-level arrays emit a type alias for the element type.
- What about nullable fields?
- Mix several samples that include and omit a field, and the inferred type becomes T | null.
Related developer tools tools
- CSV to JSON ConverterConvert CSV to a JSON array of objects. Uses the first row as keys, handles quoted values, and detects common delimiters automatically.
- LLM JSON Schema ValidatorValidate JSON Schemas for OpenAI strict mode, function calling, Anthropic tool use, and Gemini controlled generation. Catch vendor-specific schema errors before shipping.
- JWT GeneratorSign JSON Web Tokens with HS256, HS384, or HS512. Set custom claims, expiry, and issuer — then copy the signed token for use in API testing or auth flows.
- String Escape/UnescapeEscape and unescape strings for JSON, JavaScript, HTML, and SQL. Handles special characters, backslashes, quotes, newlines, and Unicode escape sequences instantly.
- .gitignore GeneratorBuild a .gitignore file from community templates for any language or framework — Node, Python, Go, Java, React, Rails, and more. Select multiple templates and merge them in one click.
- .htaccess GeneratorGenerate common Apache .htaccess snippets — redirects, URL rewrites, HTTPS enforcement, custom error pages, CORS headers, and caching rules. Copy the snippet you need.
Related reading
- LLM Token Counting: GPT, Claude, Llama & Gemini ExplainedA practical guide to LLM tokens — how they work, why each model counts differently, real cost calculations at scale, and how to count tokens before sending a request.
- JSON Formatting Guide: Pretty-Print & Validate Like a ProEverything you need to know about JSON formatting — indentation rules, minification for production, common validation errors, and how to convert between JSON and other formats.