PlayWithJSON

JSON to GraphQL Schema Generator

GraphQL SDL

Convert any JSON or JSON5 payload into GraphQL types, inputs, queries, and mutations instantly in your browser.

Samples:
Indent:
JSON / JSON5 InputJSON
19 lines | 409 charsJSON
GraphQL Schema OutputGQL
type User {
  status: String
  statusCode: Int
  data: Data
  timestamp: String
}

type Profile {
  firstName: String
  lastName: String
  skills: [String]
}

type Preferences {
  theme: String
  notifications: Boolean
}

type Data {
  userId: ID
  username: String
  email: String
  profile: Profile
  preferences: Preferences
}

input UserInput {
  status: String
  statusCode: Int
  data: DataInput
  timestamp: String
}

input ProfileInput {
  firstName: String
  lastName: String
  skills: [String]
}

input PreferencesInput {
  theme: String
  notifications: Boolean
}

input DataInput {
  userId: ID
  username: String
  email: String
  profile: ProfileInput
  preferences: PreferencesInput
}

type Query {
  getUser(id: ID!): User
  listUsers: [User!]!
}
56 lines | 762 charsGQL

JSON to GraphQL Schema Generator Online

Convert JSON and JSON5 data into clean GraphQL Schema Definition Language (SDL) types, input types, queries, and mutations instantly.

Nested JSON objects are extracted into separate named types, arrays are mapped with bracket syntax, and ID keys are automatically inferred. Fast, privacy-safe, and runs entirely in your browser.

{}

Why Use PlayWithJSON?

  • Instant GraphQL SDL types generation from any JSON payload
  • Generates corresponding input types for mutations and forms
  • Automatic Query and Mutation operation definitions
  • Intelligent ID scalar detection (id, _id, userId)
  • 100% client-side with no servers or tracking

Key Features of JSON to GraphQL Converter

SDL Type Extraction

Transforms objects into GraphQL SDL type declarations with proper scalar mapping.

Input Types Support

Generates parallel input types (e.g. UserInput) with nested input types for GraphQL mutations.

Query & Mutation Boilerplate

Optionally outputs standard CRUD queries (get, list) and mutations (create, update, delete).

Nullable & Required Toggles

Easily toggle non-null exclamation marks (!) across all fields or keep them nullable.

Smart ID Detection

Automatically detects identifier fields and types them as ID instead of String or Int.

Export to .graphql File

Copy to clipboard or download the generated schema directly as a .graphql file for Apollo, Relay, or Yoga.

How to Convert JSON to GraphQL SDL

1

Paste JSON Data

Paste any JSON response or sample model into the left editor.

2

Set Root Type Name

Choose a PascalCase name for your root type such as User, Product, or Order.

3

Configure Options

Enable inputs, queries, mutations, or non-nullable field enforcement.

4

Copy or Download

Download your schema.graphql file or copy the SDL directly.

JSON to GraphQL SDL Example

JSON (Input)
{ "id": "usr_99", "name": "Asha Sharma", "age": 28, "isActive": true, "skills": ["GraphQL", "TypeScript"], "company": { "name": "Tech Corp", "city": "Bengaluru" } }
GraphQL SDL (Output)
1type User {
2 id: ID
3 name: String
4 age: Int
5 isActive: Boolean
6 skills: [String]
7 company: Company
8}
9
10type Company {
11 name: String
12 city: String
13}
14
15input UserInput {
16 id: ID
17 name: String
18 age: Int
19 isActive: Boolean
20 skills: [String]
21 company: CompanyInput
22}
23
24input CompanyInput {
25 name: String
26 city: String
27}
28
29type Query {
30 getUser(id: ID!): User
31 listUsers: [User!]!
32}

Schema Validation Rules

Invalid JSON
1{
2 id: 123 // missing quotes
3}
Syntax error: invalid JSON key syntax
Valid JSON
1{
2 "id": 123,
3 "title": "Clean Architecture"
4}

Supported GraphQL Features

GraphQL Schema Definition Language (SDL)
Scalar inference (String, Int, Float, Boolean, ID)
List types with bracket syntax ([Type])
Nested type extraction (PascalCase)
Mirror input types for mutations
Pre-built Query and Mutation operations
Customizable indentation (2 or 4 spaces)
Works with Apollo Server, GraphQL Yoga, Hasura, and Relay
100% in-browser offline processing
Frequently Asked Questions

Frequently Asked Questions about JSON to GraphQL

Each nested object is extracted into its own distinct GraphQL type with a PascalCase name derived from the property key.

More JSON Developer Tools

View All Tools

JSON Formatter

Format, validate and inspect JSON data

JSON5 Formatter

Format and validate JSON5 with comments

JSON ↔ JSON5

Convert between JSON and modern JSON5

JSON to TypeScript

Generate TypeScript interfaces from JSON

JSON to Zod

Generate Zod schemas from JSON

Text to JSON

Convert text and schemas into structured JSON

JSON Sorter Online

Sort JSON keys alphabetically and order arrays

JWT Decoder Online

Decode JWT header, payload and expiration

JSON Stringify Online

Escape quotes and stringify or unescape JSON

Mock JSON Generator

Generate realistic mock data for APIs and testing

JSON to CSV

Export structured JSON arrays into CSV spreadsheets

JSONPath Tester

Query and filter JSON data with path expressions

JSON Schema Generator

Generate JSON Schema from sample JSON

JSON Diff & Compare

Compare two JSON objects and find differences

JSON ↔ YAML

Convert JSON/JSON5 to YAML and back with comments

JSON ↔ XML

Convert JSON to XML and XML to JSON with attributes

YAML to CSV

Convert YAML lists and objects into spreadsheets

CSV to JSON / JSON5

Convert CSV/TSV to JSON or JSON5 with type parsing

JSON to BigQuery

Generate BigQuery Schema JSON and CREATE TABLE DDL

JSON to GraphQL

Generate GraphQL SDL types, queries, and inputs

JSON to MySQL

Generate MySQL CREATE TABLE DDL and INSERT queries

JSON to PostgreSQL

Generate PostgreSQL CREATE TABLE DDL, JSONB and INSERTs

JSON Flattener

Flatten nested JSON to dot notation or unflatten back

JSON Tree Visualizer

Interactive SVG mindmap graph and collapsible node tree

JSON Minifier Online

Compact and compress JSON by stripping whitespace

JSON Token Counter

Calculate LLM tokens (GPT-4o, Claude) and API costs

Broken JSON Repair

Automatically heal broken and truncated AI/LLM JSON