JSON to GraphQL

Generate a GraphQL schema from JSON. Paste a sample payload and get SDL type definitions for every nested object, with lists, Int versus Float, ID fields and non-null markers worked out from the data — plus a query that selects every field. Anything that needs a decision, like a field that mixes types, is listed. It's free, runs in your browser, and nothing is uploaded.

JSON to GraphQL scalars

JSONGraphQL
"text"String
42Int
4.2Float
trueBoolean
id: 42 / "a1"ID
[ … ][Type]
{ … }type Name { … }

When to use it

  1. Sketch a GraphQL schema from an existing REST response.
  2. Wrap a JSON API with GraphQL without typing every type by hand.
  3. Generate a full-selection query to test a resolver.
  4. Teach how JSON structures map to GraphQL types.

How to Use

  1. Paste JSON or drop a .json file.
  2. Set the root type name and options.
  3. Copy the SDL and the generated query.

Features

  1. Nested types and lists
  2. Int, Float, ID detection
  3. Non-null inference
  4. Invalid name conversion
  5. Full-selection query
  6. 100% client-side

FAQs

How are numbers typed?

Whole numbers become Int and decimals become Float, based on every value in the sample.

When is a field non-null (!)?

When it's present in every object and never null. Fields missing from some items, or sometimes null, stay nullable.

Why map id to ID?

ID is GraphQL's identifier scalar; clients like Apollo and Relay use it for caching. Turn the option off to keep Int or String.

What happens to keys like first-name?

GraphQL names can't contain hyphens, so they become firstName and are listed below the options.

Is my JSON uploaded?

No. Everything runs in your browser.

Technical Details

The generator infers one shape from the whole sample, merging every object in an array so fields that appear only sometimes aren't lost, then writes a GraphQL type for each object, root first. Scalars map to GraphQL's built-ins: whole numbers to Int, decimals to Float, text to String, booleans to Boolean, and — optionally — keys named id or ending in Id or _id to ID, which GraphQL clients use for caching. Arrays become list types, with the item type named from the singular of the key. With non-null on, a field that is present in every sample and never null gets !, including inside lists ([Post!]!), while optional or nullable fields stay nullable. Keys that aren't valid GraphQL names, such as first-name, are converted to camelCase and listed, and fields that mix types or are only ever null are typed as String with a note suggesting a union or custom scalar. A query that selects every field, nested to any depth, is generated alongside the schema.

Developer Tools

Developer Tools

  • Regex Escape & Extract
  • AI Prompt Generator
  • Combine Files for AI
  • Freelance Rate Calculator
  • H-1B Wage Level Worksheet
  • Keyboard Tester
  • localStorage Viewer
  • Public API Directory