JSON Formatter & Validator
Format, validate, and minify JSON before generating types from it.
Paste any JSON payload and get clean TypeScript interfaces back. The converter handles nested objects, arrays of mixed shapes, optional fields, and union types — useful when you need types for an API response, a configuration file, or a third-party payload that has no published schema. Everything runs in your browser, so even sensitive payloads stay on your device.
Root, but pick something descriptive like User, ApiResponse, or Order so the generated types read well in your project.interface and type, switch unknown for any, mark fields readonly, or prepend export if you'll paste into a module.?.types.ts file. Manually refine any null-only fields if you know the non-null type, since the converter only sees what's in the sample.TypeScript projects that consume JSON data — REST or GraphQL responses, NDJSON streams, configuration files, message-queue payloads — need types that match the runtime shape exactly. Hand-writing those types is tedious and error-prone, and a single missed optional field can break compilation hours into a refactor. This tool generates the types automatically from a sample of real data, so you can paste an API response and get back a usable starting point in seconds.
The conversion is purely structural: it looks at the shape of the JSON and emits one interface per distinct nested object. Arrays produce T[] types where T is the unified type of every element seen. When an array contains multiple objects with slightly different keys, the converter merges all keys into a single interface and marks any non-shared field as optional. Mixed primitive arrays produce union types — for example, [1, "two"] becomes (number | string)[].
Generated types are a starting point, not a substitute for a real schema. JSON does not distinguish between "this field is always present and always a string" and "this field happened to be a string in the one example I saw." If your data has fields that vary in shape based on a discriminator, or fields that can legitimately be any of several primitive types, you'll need to refine the output by hand. The tool's job is to do the boring 90% so you can focus on the interesting 10%.
Given this JSON input:
The converter produces:
Notice that pinned is optional because only one of the two posts has it, posts is automatically singularized to Post, and avatar is marked optional because its only observed value was null. You'll typically want to update avatar by hand to string | null if you know it will hold a URL when present.