JSON ~ TypeScript

중첩된 개체 지원을 사용하여 JSON에서 TypeScript 인터페이스를 생성합니다.

무료 온라인 JSON ~ TypeScript 생성기

API 응답에 대한 손 쓰기 인터페이스를 중지합니다. JSON을 붙여넣고 별도의 유형으로 분할된 중첩 객체와 자동으로 추론되는 배열 요소 모양이 있는 TypeScript 인터페이스를 가져옵니다.

루트 인터페이스의 이름을 지정하고 출력을 프로젝트에 복사한 다음 전체 유형 안전을 위해 fetch 또는 HTTP 클라이언트와 함께 사용하세요. 모든 것이 브라우저에서 클라이언트 측에서 실행됩니다.

Frequently Asked Questions

What TypeScript types are generated?
Primitive JSON values map to string, number, boolean, and null. Arrays become Type[] with the element type inferred from the first item. Objects become interfaces with named properties. Nested objects generate separate interface definitions.
How are optional fields handled?
Properties present in the sample JSON are included as required fields. If you need optional fields, add them to your sample JSON with null values, or manually add ? to the generated interface properties.
Can I name the root interface?
Yes. Set a custom root interface name before generating. Nested interfaces are named automatically based on property names (e.g., Address for an address object).
Does this handle union types?
The generator infers types from a single sample. If a field can be string or number, provide samples that include both variants, or manually adjust the generated type to a union (string | number).
Is the output compatible with strict TypeScript?
Yes. Generated interfaces use standard TypeScript syntax compatible with strict mode. Review nullable fields - JSON null maps to null in the type, not undefined. Adjust to field?: Type | null if needed.