JSON a TypeScript
Infiere un tipo TypeScript desde un ejemplo JSON.
JSON a TypeScript
Type or paste to update the result automatically.
Your result appears here
Type, paste, or use an example. Copy your result when it is ready.
Cómo usar JSON a TypeScript
JSON to TypeScript infers a TypeScript type from a JSON example and outputs it as a single exported type alias with a name you choose. Nested objects become inline object types, arrays become Array types with a union of element types, and empty arrays become unknown[]. Optional fields cannot be detected from a single example.
- Escribe o pega tu fuente, o carga un ejemplo.
- Cambia los ajustes básicos o abre el modo avanzado para afinar el resultado.
- Revisa y copia o descarga tu resultado. Pausa los resultados en vivo para ejecutar manualmente. Las fuentes o ajustes individuales de más de 20,000 caracteres requieren una ejecución explícita.
Qué admite esta herramienta
Infiere un tipo TypeScript desde un ejemplo JSON.
- Nombre del tipo raíz
- Set this value for your task.
Límites y procesamiento
Las operaciones de texto aceptan generalmente hasta 2,000,000 caracteres. Los analizadores, generadores y fórmulas individuales aplican límites adicionales que muestran sus controles.
Fuente de ejemplo
{"name":"ToolCabana","count":2}Preguntas frecuentes
How do I generate a TypeScript type from JSON?
Paste a JSON example, set the Root type name, and run the tool. The result is an export type declaration describing every property and nested value in the example.
Does JSON to TypeScript detect optional properties?
No. The type is inferred from the single example given, so every key present is required and keys that are absent cannot be inferred. Edit the type to add optional markers.
How are arrays with mixed values typed?
The element types are combined into a union, so an array holding strings and numbers becomes an Array type of string | number. An empty array becomes unknown[].
¿Dónde se procesa mi entrada?
Esta operación procesa su fuente en tu navegador. Copiar y descargar son acciones explícitas; la entrada de origen no se guarda en una cuenta ni en un historial.
¿Cuáles son los límites de entrada?
Las operaciones de texto aceptan generalmente hasta 2,000,000 caracteres. Los analizadores, generadores y fórmulas individuales aplican límites adicionales que muestran sus controles.