New blogMaking an AI Agent You Can Trust With Money

★ GraphQL · from JSON

JSON to GraphQL Converter

GraphQL SDL from a sample response: fields that were always present become non-null (!), id keys become ID, timestamps use a DateTime scalar, and anything untyped falls back to a JSON scalar.

  • Runs in your browser
  • No signup

Strictness

Your JSON

GraphQL

3 types · 16 fields
scalar DateTime
scalar JSON

type Root {
  id: ID!
  email: String!
  displayName: String!  # JSON key: "display-name"
  createdAt: DateTime!
  plan: JSON
  tags: [String!]!
  team: Team!
  invoices: [Invoice!]!
}

type Invoice {
  number: String!
  amount: Float!
  paid: Boolean!
  paidAt: DateTime
  note: String
}

type Team {
  id: ID!
  name: String!
  website: String!
}

Typing APIs by hand?

I set up end-to-end type safety (DB → API → UI) so this never happens again.

Fix my types
01

How the GraphQL mapping works

Each JSON value is read, merged with every other sample of the same key, and then mapped to the closest GraphQL type:

JSON to GraphQL mapping
In your JSONGraphQL
stringString
timestampDateTime (custom scalar)
integer / decimalInt / Float
key "id"ID
present in every sample, never nullT!
null or missingT (nullable)
array[T!]!
mixed values or always nullJSON (custom scalar)
dashed keycamelCase field + comment with the original key
02

Worked example

A user record with a nested team, a list of invoices (one missing a note, one with a null payment date) and an awkward display-name key:

{
  "id": 1042,
  "email": "ada@example.com",
  "display-name": "Ada",
  "createdAt": "2026-11-07T09:30:00Z",
  "plan": null,
  "tags": ["beta", "founder"],
  "team": {
    "id": "7f3c9a2e-1b4d-4c8e-9f2a-6d5e4c3b2a19",
    "name": "Analytical Engines",
    "website": "https://example.com"
  },
  "invoices": [
    { "number": "INV-001", "amount": 49.5, "paid": true, "paidAt": "2026-10-01T00:00:00Z" },
    { "number": "INV-002", "amount": 49, "paid": false, "paidAt": null, "note": "Card declined" }
  ]
}

Becomes this GraphQL, generated by the same engine that runs the converter above (3 types, 16 fields):

scalar DateTime
scalar JSON

type Root {
  id: ID!
  email: String!
  displayName: String!  # JSON key: "display-name"
  createdAt: DateTime!
  plan: JSON
  tags: [String!]!
  team: Team!
  invoices: [Invoice!]!
}

type Invoice {
  number: String!
  amount: Float!
  paid: Boolean!
  paidAt: DateTime
  note: String
}

type Team {
  id: ID!
  name: String!
  website: String!
}
03

GraphQL gotchas

Int is 32-bit

GraphQL Int stops at about 2.1 billion. Large counters and money in cents may need Float, a string or a custom scalar.

Custom scalars need resolvers

DateTime and JSON are declared but not built in. Add them from a library like graphql-scalars or write their serialize and parse functions.

Field names must be valid

GraphQL names can't contain dashes. Renamed fields keep a comment with the JSON key so your resolver can map it.

04

Questions developers actually ask

Why is every field non-null?
They appeared with a value in every sample. Paste more varied samples and fields that are sometimes missing or null lose the !.
How are unions handled?
Mixed-type fields become the JSON scalar. Model them as a GraphQL union or interface once you know the possible shapes.
Does this generate resolvers or a full schema?
It generates type definitions. Add a Query type that returns the root type, then write resolvers that fetch the data.
Is my JSON sent to a server?
No. Parsing and type generation run in your browser, so you can paste real API responses with tokens or customer data. Nothing leaves the tab.
How does it know a field is optional?
Paste an array of objects, or a response that contains one. Every element is read and merged: keys missing from some elements become optional, and keys that are sometimes null become nullable.
05

Other languages

06

More from the workbench

Fine print

Tools: on the house.
Engineer: by the hour.

A codebase that doesn't need this tool is the upgrade. I set up end-to-end type safety so your API, database and UI agree by construction.

I'm Himanshu, an AI and full-stack engineer. I build MVPs, AI agents and the growth plumbing around them for early-stage startups.