TL
Tool Lab
💰Donate
💰Donate

JSON to GraphQL Types

Convert a JSON object into GraphQL type definitions automatically.

About This Tool

The JSON to GraphQL Generator automatically creates GraphQL type definitions from a JSON object. Each JSON key becomes a GraphQL field, and value types are inferred as Boolean!, Int!, Float!, String!, nested types, or arrays.

Nested objects generate separate GraphQL types, and arrays are inferred from the first element. Null values are treated as nullable String. All processing runs in your browser.

How to Use

  1. Paste a JSON object into the left panel or modify the default example.
  2. Modify the input and the GraphQL types update in real time in the right panel.
  3. Copy the generated GraphQL schema and paste it into a .graphql file or schema builder.
  4. Adjust the types as needed — make fields nullable, add descriptions, or rename types.

Use Cases

Draft a GraphQL schema from a REST API response. Convert existing JSON data structures to type definitions for a GraphQL migration. Generate GraphQL resolver return types from API response JSON.

FAQ

  • What are the type inference rules?JSON boolean → Boolean!, JSON integer → Int!, JSON float → Float!, JSON string → String!, JSON array → [Type] (inferred from first element), JSON object → nested type.
  • Can I use the generated schema directly?No. The generated schema is a starting point. You will need to manually add ? for optional fields, adjust nullable types, add descriptions and directives, etc.
  • How are arrays handled?Arrays are typed as [Type] inferred from the first element. Empty arrays default to [String].