GraphQL Formatter

Beautify any GraphQL in one paste.

Free online GraphQL pretty-printer for queries, mutations, fragments, and schemas. Indents by depth, preserves comments and block strings, validates brace balance.

2 or 4 spacePreserves commentsBrace balance check

GraphQL input

Paste a query, mutation, fragment, or full SDL schema. Strings and comments are preserved.

11 lines·390 chars
Braces and parens balance — looks structurally valid.
Formatted GraphQLgraphql
query GetUser($id: ID!, $includePosts: Boolean = false) {
  user(id: $id) {
    id name email avatarUrl posts(first: 10, orderBy: CREATED_DESC) @include(if: $includePosts) {
      edges {
        node {
          id title publishedAt comments(first: 3) {
            totalCount nodes {
              author {
                id name
              }
              body
            }
          }
        }
      }
      pageInfo {
        hasNextPage endCursor
      }
    }
  }
}
# A reusable fragment
fragment AuthorBits on User {
  id
  name
  avatarUrl
}

Documenting a GraphQL API?

Dokly publishes GraphQL schema docs alongside REST and MDX content — search, theming, and AI-ready out of the box.

Try Dokly free →

What this formatter does (and doesn't)

The formatter walks your GraphQL character by character and re-emits it with consistent indentation. It keeps the things you want kept — strings, block strings (""" ... """), and comments (#) — and standardizes the rest: one field per line, two- or four-space indent based on brace depth, argument lists kept inline.

When to use it

  • Cleanup pasted queries: an API consumer dumped a one-liner — paste it here for a readable version.
  • Format a schema: normalize a hand-edited .graphql file before committing.
  • Embed in docs: paste a clean version into your MDX so readers can follow the shape of a request.

What it doesn't do

  • It is not a full GraphQL parser. It won't catch every syntax error — only mismatched braces, parens, and unterminated strings.
  • It does not introspect schemas, run queries, or validate fields against a type system. It's a formatter, not a client.

Privacy

Everything runs in your browser. Your queries and schema never leave your machine.