Dev Tools

JSON to GraphQL Schema

Generate GraphQL type definitions from a JSON example object.

Root Type Name
JSON Input
GraphQL Schema
type RootAddress {
  street: String
  city: String
  zip: String
}

type RootPosts {
  id: Int
  title: String
  published: Boolean
}

type Root {
  id: Int
  name: String
  email: String
  active: Boolean
  score: Float
  tags: [String]
  address: RootAddress
  posts: [RootPosts]
}
Was this page helpful?

Related tools

About JSON to GraphQL Schema

Turn a JSON sample into GraphQL Schema Definition Language (SDL) types, mapping JSON fields to GraphQL scalars and nested types. A quick starting point when modelling an API or mock schema from existing data.

How to use

  1. Paste a JSON object that represents your data.
  2. Review the generated GraphQL type definitions and nested types.
  3. Copy the SDL into your schema and refine nullability and custom scalars.

Frequently asked questions

How are numbers mapped?
Integers map to Int and decimals to Float; you can adjust these in the generated SDL if your API uses custom scalars.
Does it create input types?
It generates object types from the sample; input types and resolvers are left for you to add based on your API design.