★ 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
Convert to
Strictness
Your JSON
GraphQL
3 types · 16 fieldsscalar 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.
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:
| In your JSON | GraphQL |
|---|---|
| string | String |
| timestamp | DateTime (custom scalar) |
| integer / decimal | Int / Float |
| key "id" | ID |
| present in every sample, never null | T! |
| null or missing | T (nullable) |
| array | [T!]! |
| mixed values or always null | JSON (custom scalar) |
| dashed key | camelCase field + comment with the original key |
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!
}
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.
Questions developers actually ask
Why is every field non-null?
How are unions handled?
Does this generate resolvers or a full schema?
Is my JSON sent to a server?
How does it know a field is optional?
Other languages
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.
