Generador de clases desde JSON

Convierte un ejemplo JSON en clases de modelo o interfaces TypeScript.

// about

Sobre esta herramienta

La herramienta infiere la estructura JSON y genera código inicial. Revisa campos opcionales, objetos anidados y tipos.

Cómo usarla

  1. Pega un objeto o matriz JSON.
  2. Elige el lenguaje y la clase raíz.
  3. Genera, revisa los tipos y copia el código.

Por qué usar esta herramienta

  • Convierte respuestas JSON de API en modelos.
  • Genera código para cinco lenguajes.
  • Permite revisar objetos y matrices anidadas.

Preguntas frecuentes (FAQ)

¿Está listo para producción?

Es un punto de partida; comprueba tipos y campos según tu API.

Guías · Datos · 8 min de lectura

Corregir errores de sintaxis JSON: los 7 fallos más comunes y cómo ordenar un JSON

Respuestas de API, archivos de configuración, registros: JSON es el formato de datos que más leen los desarrolladores. Aun así, una sola coma o comilla puede provocar un error «Unexpected token». Así puedes encontrar la causa rápidamente.

JSON (JavaScript Object Notation) es un formato de texto estandarizado en la RFC 8259 y ECMA-404. Nació de JavaScript, pero hoy lo admiten casi todos los lenguajes. Solo hay seis tipos de valor: cadena, número, booleano (true/false), null, array y objeto.

{
  "id": 1024,
  "name": "AIBIZAP",
  "active": true,
  "tags": ["tools", "guides"],
  "owner": null
}
Conceptos básicos de JSON, siete errores de análisis frecuentes, trampas con números grandes y fechas, y cómo convertir JSON en clases o tablas.
Leer guía →
Créalo con IA

Crea esta herramienta tú mismo con IA

¿Quieres tu propia versión? Copia el prompt en un chat de IA o guarda el archivo de skill para un agente de programación. Incluyen las funciones, casos límite y pruebas que usamos al crearla.

El prompt y la skill están en inglés, que las herramientas de IA entienden perfectamente.

Prompt de instrucciones para IA

Pégalo tal cual en Claude, ChatGPT o Gemini.

You are an experienced full-stack web developer. Build a web tool called "Generador de clases JSON" that meets the requirements below.

## Goal

Build a tool that generates C#, Java, Python and TypeScript model classes from a JSON sample.

## Core features

- Choose C#, Java, Python dataclasses or TypeScript interfaces
- Create separate classes for nested objects
- Infer array element types
- Set the root class name
- Apply each language's naming conventions

## Inputs

- JSON sample
- Target language and root class name

## Outputs

- Generated code
- Summary of inferred types

## Edge cases and handling rules

- Treat null values as nullable types
- Merge differing keys across array elements
- Handle keys that clash with reserved words
- Keep original names for keys with digits or hyphens via serialization attributes

## Implementation requirements

- Build it as a single page (HTML, CSS, JavaScript) that runs entirely in the browser, and never send the user's input to a server.
- Make the UI responsive and easy to use on mobile; label every input and keep everything keyboard accessible.
- Add a Copy button for results and show clear, friendly error messages for invalid input.
- Keep the core logic in functions separate from the UI so it can be unit-tested.

## Definition of done (test cases)

- {"id":1,"name":"a"} gives int Id and string Name in C#
- Nested objects become separate classes
- Empty arrays become lists of object/any

First outline your implementation plan in at most five lines, then write the complete code, and finally explain how to check the test cases above.

Skill (SKILL.md)

Guárdalo como .claude/skills/build-json-class-generator/SKILL.md para que agentes como Claude Code lo reutilicen cada vez que crees o cambies la herramienta.

---
name: build-json-class-generator
description: Use when building or changing a Generador de clases JSON tool. Build a tool that generates C#, Java, Python and TypeScript model classes from a JSON sample.
---

# Build: Generador de clases JSON

## Goal

Build a tool that generates C#, Java, Python and TypeScript model classes from a JSON sample.

## Workflow

1. Review the required features, inputs and outputs below and ask about anything missing first.
2. Implement the core logic as pure functions separate from the UI.
3. Check the logic against the test cases in the verification list.
4. Build a responsive UI with an input form, a result area and a Copy button.
5. Reproduce each edge case listed under Rules and refine the error messages.

## Core features

- Choose C#, Java, Python dataclasses or TypeScript interfaces
- Create separate classes for nested objects
- Infer array element types
- Set the root class name
- Apply each language's naming conventions

## Inputs

- JSON sample
- Target language and root class name

## Outputs

- Generated code
- Summary of inferred types

## Rules

- Treat null values as nullable types
- Merge differing keys across array elements
- Handle keys that clash with reserved words
- Keep original names for keys with digits or hyphens via serialization attributes
- Build it as a single page (HTML, CSS, JavaScript) that runs entirely in the browser, and never send the user's input to a server.

## Verification

- [ ] {"id":1,"name":"a"} gives int Id and string Name in C#
- [ ] Nested objects become separate classes
- [ ] Empty arrays become lists of object/any

Consejos para trabajar con IA

  • Indica tu stack (React, Vue o HTML puro) en la primera línea para obtener código adecuado.
  • Pide que ejecute las pruebas listadas y muestre los resultados antes de aceptar el código.
  • No pegues contraseñas reales, datos de clientes ni claves de API; usa valores de ejemplo.