Content-Type for GraphQL Requests

Set the correct Content-Type header for GraphQL API requests. Covers why application/json is the standard for GraphQL over HTTP.

JSON APIs

Detailed Explanation

GraphQL Over HTTP

GraphQL requests are typically sent as JSON payloads over HTTP POST. The standard Content-Type is application/json; charset=utf-8, the same as any JSON API.

The Header Value

Content-Type: application/json; charset=utf-8

Request Body Structure

A GraphQL request body is a JSON object with query, optional variables, and optional operationName fields:

{
  "query": "query GetUser($id: ID!) { user(id: $id) { name email } }",
  "variables": { "id": "123" },
  "operationName": "GetUser"
}

Why Not a Custom MIME Type?

While there is a proposed application/graphql+json media type (part of the GraphQL over HTTP specification draft), the vast majority of GraphQL servers and clients use plain application/json. Using a different Content-Type may cause the server to reject the request.

Alternative: application/graphql

Some older GraphQL servers accept application/graphql where the body is the raw query string (not wrapped in JSON). This is non-standard and not recommended for new implementations.

curl Example

curl -X POST \
  -H "Content-Type: application/json; charset=utf-8" \
  -d '{"query":"{ users { id name } }"}' \
  https://api.example.com/graphql

Use Case

Use this when integrating with GraphQL APIs, whether building a frontend with Apollo Client, Relay, or making direct HTTP calls. Works with all major GraphQL server implementations.

Try It — Content-Type Header Builder

Open full tool