# JSON a TypeScript

> Infiere un tipo TypeScript desde un ejemplo JSON.

[Open tool](https://www.toolcabana.com/es/json-to-typescript) · [Desarrollo y datos](https://www.toolcabana.com/es/category/developer-and-data)

Tool ID: json-to-typescript. Requested language: es. Description language: es. Complete guide translation: yes.

## Overview (en)

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.

## Supported tasks (es)

Infiere un tipo TypeScript desde un ejemplo JSON.

## Steps (es)

1. Escribe o pega tu fuente, o carga un ejemplo.
2. Cambia los ajustes básicos o abre el modo avanzado para afinar el resultado.
3. 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.

## Settings

- Nombre del tipo raíz (es; key: name; type: text)

## Limitations (es)

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.

## Example input

```text
{"name":"ToolCabana","count":2}
```

## Privacy and connections (es)

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.

## Questions (es)

### 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.

## Related tools

- [JSON to Dart model](https://www.toolcabana.com/es/json-to-dart)
- [JSON to Excel](https://www.toolcabana.com/es/json-to-excel)
- [Excel to JSON](https://www.toolcabana.com/es/excel-to-json)
- [XML to JSON](https://www.toolcabana.com/es/xml-to-json)
